Hi All, Recently, I have changed *agent_check_and_process(1),* In the SNMP Subagent code to a *select() & snmp_select_info() to handle outside events* *, Please find the code snippet attached.*
I have tried to make *fakeblock=0 *too. Problem I am facing is , If Subagent Process comes up in the system before the Master Agent(*snmpd*) Process.* Subgent is not able to establish connection with Master Agent*.But if Master Agent(snmpd) process comes up before the Subagent process in the system, The connection between master Agent and Subagent is *successful.* Moreover once the connection is established between Master Agent and SubAgent, If I restart snmpd(Master Agent ) it doesn't connect back to the Subagent. Above problem is solved if I use agent_check_process(1) .i.e.The Subagent keeps on polling until it establishes connection with the master agent.( *This is default expected behaviour*). Looks like there is some problem in usage of select() and snmp_select_info() I am using net-snmp 5.8. Please help me on this 😞. *-Himanshu* /////code start from here keepRunning_=1; int maxFd; fd_set fdset; struct timeval timeout = { LONG_MAX, 0 }, *tvp = &timeout; int result; int fakeblock = 0; maxFd = 0; while (keepRunning_) { /* if you use select(), see snmp_select_info() in snmp_api(3) */ /* --- OR --- */ * //agent_check_and_process(1)*; /* 0 == don't block */ maxFd = *eventPipe_; FD_ZERO(&fdset); snmp_select_info(&maxFd, &fdset, tvp, &fakeblock); FD_SET(*eventPipe_, &fdset); maxFd = (std::max(maxFd, *eventPipe_)); result = select(maxFd+1, &fdset, NULL, NULL, NULL); if (result == -1) { if (errno != EINTR) { snmp_log_perror("select"); } continue; } else if (result == 0) { snmp_timeout(); continue; } else { if (FD_ISSET(*eventPipe_, &fdset)) { //do something } if (result > 0) { /* * packets found, process them */ snmp_read(&fdset); } else { printf("runSubAgent select returned result %d",result); } } }
_______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users