On Wed, Apr 19, 2006 at 05:35:03PM -0400, Robert Story wrote:
> On Mon, 27 Mar 2006 11:41:34 -0800 David wrote:
> Why not continue processing other fds? Instead of using a single boolean
> value, use another fdset for finer grained control.


Good point, there is no reason not to continue processing other fds.
Updated patch below.

BTW, I filed this issue as item 1460082 at
http://sourceforge.net/tracker/index...94&atid=312694
It is marked as fixed and applied, but I do not see the change in cvs.
In any case the change included in this mail should be applied instead.

-David


* snmplib/fd_event_manager.c (unregister_readfd, unregister_writefd,
unregister_exceptfd) : Set fd in 'external_unregistered_fds' whenever
a fd is unregistered.
(netsnmp_external_event_info) : Clear 'external_unregistered_fds'.
(netsnmp_dispatch_external_events) : Ensure fd is not set in
'external_unregistered_fds' before calling any external handlers.

Index: snmplib/fd_event_manager.c
================================================== =================
RCS file: /cvsroot/net-snmp/net-snmp/snmplib/fd_event_manager.c,v
retrieving revision 5.1
diff -u -p -r5.1 fd_event_manager.c
--- snmplib/fd_event_manager.c 29 Apr 2005 16:12:32 -0000 5.1
+++ snmplib/fd_event_manager.c 25 Apr 2006 17:51:15 -0000
@@ -17,6 +17,8 @@ void *external_readfd_data[NUM_EXTERNA
void *external_writefd_data[NUM_EXTERNAL_FDS];
void *external_exceptfd_data[NUM_EXTERNAL_FDS];

+static fd_set external_unregistered_fds;
+
/*
* Register a given fd for read events. Call callback when events
* are received.
@@ -96,6 +98,7 @@ unregister_readfd(int fd)
external_readfd_data[j] = external_readfd_data[j + 1];
}
DEBUGMSGTL(("fd_event_manager:unregister_readfd", "unregistered fd %d\n", fd));
+ FD_SET(fd, &external_unregistered_fds);
return FD_UNREGISTERED_OK;
}
}
@@ -119,6 +122,7 @@ unregister_writefd(int fd)
external_writefd_data[j] = external_writefd_data[j + 1];
}
DEBUGMSGTL(("fd_event_manager:unregister_writefd", "unregistered fd %d\n", fd));
+ FD_SET(fd, &external_unregistered_fds);
return FD_UNREGISTERED_OK;
}
}
@@ -143,6 +147,7 @@ unregister_exceptfd(int fd)
}
DEBUGMSGTL(("fd_event_manager:unregister_exceptfd", "unregistered fd %d\n",
fd));
+ FD_SET(fd, &external_unregistered_fds);
return FD_UNREGISTERED_OK;
}
}
@@ -155,6 +160,9 @@ unregister_exceptfd(int fd)
void netsnmp_external_event_info(int *numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
{
int i;
+
+ FD_ZERO(&external_unregistered_fds);
+
for (i = 0; i < external_readfdlen; i++) {
FD_SET(external_readfd[i], readfds);
if (external_readfd[i] >= *numfds)
@@ -179,7 +187,8 @@ void netsnmp_dispatch_external_events(in
{
int i;
for (i = 0; *count && (i < external_readfdlen); i++) {
- if (FD_ISSET(external_readfd[i], readfds)) {
+ if (FD_ISSET(external_readfd[i], readfds) &&
+ !FD_ISSET(external_readfd[i], &external_unregistered_fds)) {
DEBUGMSGTL(("fd_event_manager:netsnmp_dispatch_external_events",
"readfd[%d] = %d\n", i, external_readfd[i]));
external_readfdfunc[i] (external_readfd[i],
@@ -189,7 +198,8 @@ void netsnmp_dispatch_external_events(in
}
}
for (i = 0; *count && (i < external_writefdlen); i++) {
- if (FD_ISSET(external_writefd[i], writefds)) {
+ if (FD_ISSET(external_writefd[i], writefds) &&
+ !FD_ISSET(external_writefd[i], &external_unregistered_fds)) {
DEBUGMSGTL(("fd_event_manager:netsnmp_dispatch_external_events",
"writefd[%d] = %d\n", i, external_writefd[i]));
external_writefdfunc[i] (external_writefd[i],
@@ -199,7 +209,8 @@ void netsnmp_dispatch_external_events(in
}
}
for (i = 0; *count && (i < external_exceptfdlen); i++) {
- if (FD_ISSET(external_exceptfd[i], exceptfds)) {
+ if (FD_ISSET(external_exceptfd[i], exceptfds) &&
+ !FD_ISSET(external_exceptfd[i], &external_unregistered_fds)) {
DEBUGMSGTL(("fd_event_manager:netsnmp_dispatch_external_events",
"exceptfd[%d] = %d\n", i, external_exceptfd[i]));
external_exceptfdfunc[i] (external_exceptfd[i],


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=...057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders