[Nagios-checkins] SF.net SVN: nagios:[2038] nagioscore/trunk/lib

ageric at users.sourceforge.net ageric at users.sourceforge.net
Thu Aug 2 00:45:48 UTC 2012


Revision: 2038
          http://nagios.svn.sourceforge.net/nagios/?rev=2038&view=rev
Author:   ageric
Date:     2012-08-02 00:45:47 +0000 (Thu, 02 Aug 2012)
Log Message:
-----------
lib/iobroker: Make iobroker_poll() return number of triggered fd's

This makes it possible to do some simple verification that we're
getting some sort of input from something registered with the broker.

Signed-off-by: Andreas Ericsson <ae at op5.se>

Modified Paths:
--------------
    nagioscore/trunk/lib/iobroker.c
    nagioscore/trunk/lib/iobroker.h

Modified: nagioscore/trunk/lib/iobroker.c
===================================================================
--- nagioscore/trunk/lib/iobroker.c	2012-08-02 00:45:31 UTC (rev 2037)
+++ nagioscore/trunk/lib/iobroker.c	2012-08-02 00:45:47 UTC (rev 2038)
@@ -316,7 +316,7 @@
 
 int iobroker_poll(iobroker_set *iobs, int timeout)
 {
-	int i, nfds;
+	int i, nfds, ret = 0;
 
 	if (!iobs)
 		return IOBROKER_ENOSET;
@@ -342,6 +342,7 @@
 
 		if (s) {
 			s->handler(fd, iobs->ep_events[i].events, s->arg);
+			ret++;
 		}
 	}
 #elif defined(IOBROKER_USES_SELECT)
@@ -386,6 +387,7 @@
 					continue;
 				}
 				s->handler(s->fd, POLLIN, s->arg);
+				ret++;
 			}
 		}
 	}
@@ -420,9 +422,10 @@
 				continue;
 			}
 			s->handler(s->fd, (int)iobs->pfd[i].revents, s->arg);
+			ret++;
 		}
 	}
 #endif
 
-	return 0;
+	return ret;
 }

Modified: nagioscore/trunk/lib/iobroker.h
===================================================================
--- nagioscore/trunk/lib/iobroker.h	2012-08-02 00:45:31 UTC (rev 2037)
+++ nagioscore/trunk/lib/iobroker.h	2012-08-02 00:45:47 UTC (rev 2038)
@@ -149,6 +149,7 @@
  * Wait for input on any of the registered sockets.
  * @param iobs The socket set to wait for.
  * @param timeout Timeout in milliseconds. -1 is "wait indefinitely"
+ * @return -1 on errors, or number of filedescriptors with input
  */
 extern int iobroker_poll(iobroker_set *iobs, int timeout);
 #endif /* INCLUDE_iobroker_h__ */

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Nagios-commits mailing list