If we have fork()ed, in addition to exiting poll() if a fd is active, also
wake up once a second.

This should ensure defunct processes are retired in a timely fashion,
while also minimizing wakeups while not needing to reap, i.e. most of the
time.

Change reap_count to an unsigned int, strictly to turn off that part of
readers' brains where they worry it might ever be negative.

Fix a typo in comment.

Signed-off-by: Andy Grover <agro...@redhat.com>
---
 usr/event_poll.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/usr/event_poll.c b/usr/event_poll.c
index a4ab3ea..8482d6f 100644
--- a/usr/event_poll.c
+++ b/usr/event_poll.c
@@ -39,7 +39,9 @@
 #include "initiator.h"
 #include "iscsi_err.h"
 
-static int reap_count;
+static unsigned int reap_count;
+
+#define REAP_WAKEUP 1000 /* in millisecs */
 
 void reap_inc(void)
 {
@@ -52,7 +54,7 @@ void reap_proc(void)
 
        /*
         * We don't really need reap_count, but calling wait() all the
-        * time seems execessive.
+        * time seems excessive.
         */
        max_reaps = reap_count;
        for (i = 0; i < max_reaps; i++) {
@@ -169,7 +171,7 @@ void event_loop(struct iscsi_ipc *ipc, int control_fd, int 
mgmt_ipc_fd)
                /* Runs actors and may set alarm for future actors */
                actor_poll();
 
-               res = poll(poll_array, POLL_MAX, -1);
+               res = poll(poll_array, POLL_MAX, reap_count ? REAP_WAKEUP : -1);
 
                if (res > 0) {
                        log_debug(6, "poll result %d", res);
-- 
1.9.3

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to