[ZBX-14855] misleading process type assignment Created: 2018 Sep 15  Updated: 2024 Apr 10  Resolved: 2018 Dec 11

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: 3.4.14, 4.0.0beta2
Fix Version/s: 3.0.25rc1, 4.0.3rc1, 4.2.0alpha2, 4.2 (plan)

Type: Problem report Priority: Trivial
Reporter: Mikhail Makurov Assignee: Andrejs Sitals
Resolution: Fixed Votes: 0
Labels: codequality
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Team: Team A
Team: Team A
Sprint: Sprint 46, Nov 2018, Sprint 47, Dec 2018
Story Points: 0.125

 Description   

While playing around with sources and adding new type of poller i found a misconcept in the code wich i suggest to fix:

On server.c there is a switch  which assigns type of poller depending of type of process:
switch (thread_args.process_type)
        {
            case ZBX_PROCESS_TYPE_CONFSYNCER:
                threads[i] = zbx_thread_start(dbconfig_thread, &thread_args);
                break;
            case ZBX_PROCESS_TYPE_POLLER:
                poller_type = ZBX_PROCESS_TYPE_POLLER;
                thread_args.args = &poller_type;
                threads[i] = zbx_thread_start(poller_thread, &thread_args);
                break;
            case ZBX_PROCESS_TYPE_UNREACHABLE:
                poller_type = ZBX_PROCESS_TYPE_UNREACHABLE;
                thread_args.args = &poller_type;
                threads[i] = zbx_thread_start(poller_thread, &thread_args);
                break;
 
This however there are also poller types defined in dbcache.h
I suggest assigning instead of asigning

poller_type=ZBX_PROCESS_TYPE_UNREACHABLE;

do assignement of correct poller type:

poller_type = ZBX_POLLER_TYPE_UNREACHABLE


 Comments   
Comment by Andris Mednis [ 2018 Nov 28 ]

Thanks for pointing to it!

Indeed, ZBX_PROCESS_TYPE_UNREACHABLE is a bit confusing, when compared with ZBX_PROCESS_TYPE_IPMIPOLLER, or ZBX_PROCESS_TYPE_HTTPPOLLER etc.

It seems that renaming ZBX_PROCESS_TYPE_UNREACHABLE to ZBX_PROCESS_TYPE_UNREACHABLE_POLLER is a better solution.

Process types in zbxself.h (3.0) or common.h (4.0) and poller types in dbcache.h are better to keep independent, regardless of some values which happen to be the same.

Ok, I got it wrong.

<asitals> Values that are assigned to poller_type are actually passed directly to DC*() functions and compared to ZBX_POLLER_TYPE_* constants.

andris Thanks, Mikhail and you are right!

Comment by Andris Mednis [ 2018 Nov 30 ]

Succesfully tested.

Comment by Andrejs Sitals [ 2018 Dec 03 ]

Available in versions:

  • pre-3.0.25rc1 r87495
  • pre-4.0.3rc1 r87497
  • pre-4.2.0alpha2 (trunk) r87498
Generated at Fri Apr 19 15:51:36 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.