diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2024-01-10 20:24:26 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-10 20:24:26 -0500 |
| commit | 5fbf0cc00dd751442108990026607740ff3d49d9 (patch) | |
| tree | b9ef6b55a114495002ed391227cb5de515b72cc9 /lib/agentx.c | |
| parent | 26be39c2f145630feb2ad69dc32c44c66dcb3c1f (diff) | |
| parent | 9e06f93df1867cce7c98ea63718b971ef33c0251 (diff) | |
Merge pull request #15124 from fdumontet6WIND/large_fds
lib snmp: use snmp's large fd sets for agentx
Diffstat (limited to 'lib/agentx.c')
| -rw-r--r-- | lib/agentx.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/agentx.c b/lib/agentx.c index 45f14c2703..c2f2112d7d 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -10,6 +10,7 @@ #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> #include <net-snmp/agent/snmp_vars.h> +#include <net-snmp/library/large_fd_set.h> #include "command.h" #include "smux.h" @@ -43,7 +44,7 @@ static void agentx_timeout(struct event *t) static void agentx_read(struct event *t) { - fd_set fds; + netsnmp_large_fd_set lfds; int flags, new_flags = 0; int nonblock = false; struct listnode *ln = EVENT_ARG(t); @@ -68,9 +69,9 @@ static void agentx_read(struct event *t) flog_err(EC_LIB_SYSTEM_CALL, "Failed to set snmp fd non blocking: %s(%d)", strerror(errno), errno); - FD_ZERO(&fds); - FD_SET(EVENT_FD(t), &fds); - snmp_read(&fds); + netsnmp_large_fd_set_init(&lfds, FD_SETSIZE); + netsnmp_large_fd_setfd(t->u.fd, &lfds); + snmp_read2(&lfds); /* Reset the flag */ if (!nonblock) { @@ -85,6 +86,7 @@ static void agentx_read(struct event *t) netsnmp_check_outstanding_agent_requests(); agentx_events_update(); + netsnmp_large_fd_set_cleanup(&lfds); } static void agentx_events_update(void) @@ -92,15 +94,15 @@ static void agentx_events_update(void) int maxfd = 0; int block = 1; struct timeval timeout = {.tv_sec = 0, .tv_usec = 0}; - fd_set fds; + netsnmp_large_fd_set lfds; struct listnode *ln; struct event **thr; int fd, thr_fd; event_cancel(&timeout_thr); - FD_ZERO(&fds); - snmp_select_info(&maxfd, &fds, &timeout, &block); + netsnmp_large_fd_set_init(&lfds, FD_SETSIZE); + snmp_select_info2(&maxfd, &lfds, &timeout, &block); if (!block) { event_add_timer_tv(agentx_tm, agentx_timeout, NULL, &timeout, @@ -118,7 +120,7 @@ static void agentx_events_update(void) /* caught up */ if (thr_fd == fd) { struct listnode *nextln = listnextnode(ln); - if (!FD_ISSET(fd, &fds)) { + if (!netsnmp_large_fd_is_set(fd, &lfds)) { event_cancel(thr); XFREE(MTYPE_TMP, thr); list_delete_node(events, ln); @@ -128,7 +130,7 @@ static void agentx_events_update(void) thr_fd = thr ? EVENT_FD(*thr) : -1; } /* need listener, but haven't hit one where it would be */ - else if (FD_ISSET(fd, &fds)) { + else if (netsnmp_large_fd_is_set(fd, &lfds)) { struct listnode *newln; thr = XCALLOC(MTYPE_TMP, sizeof(struct event *)); @@ -147,6 +149,7 @@ static void agentx_events_update(void) list_delete_node(events, ln); ln = nextln; } + netsnmp_large_fd_set_cleanup(&lfds); } /* AgentX node. */ |
