gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r16527 - gnunet-gtk/src/lib


From: gnunet
Subject: [GNUnet-SVN] r16527 - gnunet-gtk/src/lib
Date: Mon, 15 Aug 2011 14:40:32 +0200

Author: grothoff
Date: 2011-08-15 14:40:32 +0200 (Mon, 15 Aug 2011)
New Revision: 16527

Modified:
   gnunet-gtk/src/lib/eventloop.c
Log:
some code cleanup

Modified: gnunet-gtk/src/lib/eventloop.c
===================================================================
--- gnunet-gtk/src/lib/eventloop.c      2011-08-15 12:37:40 UTC (rev 16526)
+++ gnunet-gtk/src/lib/eventloop.c      2011-08-15 12:40:32 UTC (rev 16527)
@@ -319,39 +319,30 @@
   if (ml->cached_poll_array_size == 0)
     resize_cached_poll_array (ml, INITIAL_POLL_ARRAY_SIZE);
 
-  while (1)
-    {
-      fd_counter = 0;
+  fd_counter = 0;
 #if !WINDOWS
-      gboolean need_realloc = FALSE;
-      for (i = 0; !need_realloc && i < max_nfds; i += 1)
-       {
-         int isset[3];
+  for (i = 0; i < max_nfds; i += 1)
+    {
+      int isset[3];
          
-         isset[0] = (rfds == NULL) ? 0 : FD_ISSET (i, &rfds->sds);
-         isset[1] = (wfds == NULL) ? 0 : FD_ISSET (i, &wfds->sds);
-         isset[2] = (efds == NULL) ? 0 : FD_ISSET (i, &efds->sds);
-         if (!isset[0] && !isset[1] && !isset[2])
-           continue;
-         if (fd_counter >= ml->cached_poll_array_size)
-           {
-             need_realloc = TRUE;
-             break;
-           }
-         ml->cached_poll_array[fd_counter].fd = i;
-         ml->cached_poll_array[fd_counter].events = (isset[0] ? G_IO_IN | 
G_IO_HUP | G_IO_ERR : 0)
-           | (isset[1] ? G_IO_OUT | G_IO_ERR : 0) | (isset[2] ? G_IO_ERR : 0);
-         fd_counter++;
-       }
-      if (need_realloc)
-       {
-         resize_cached_poll_array (ml, ml->cached_poll_array_size * 2);
-         fd_counter = 0;
-         need_realloc = FALSE;
-       }
-      else
-       break;  
+      isset[0] = (rfds == NULL) ? 0 : FD_ISSET (i, &rfds->sds);
+      isset[1] = (wfds == NULL) ? 0 : FD_ISSET (i, &wfds->sds);
+      isset[2] = (efds == NULL) ? 0 : FD_ISSET (i, &efds->sds);
+      if ((! isset[0]) && (! isset[1]) && (! isset[2]))
+       continue;
+      if (fd_counter >= ml->cached_poll_array_size)
+       resize_cached_poll_array (ml, ml->cached_poll_array_size * 2);
+      ml->cached_poll_array[fd_counter].fd = i;
+      ml->cached_poll_array[fd_counter].events 
+       = (isset[0] ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0)
+       | (isset[1] ? G_IO_OUT | G_IO_ERR : 0) 
+       | (isset[2] ? G_IO_ERR : 0);
+      fd_counter++;
+    }
 #else
+  while (1)
+    {
+      fd_counter = 0;
       struct GNUNET_CONTAINER_SList_Iterator *t;
       /* We might overshoot a little, but that won't hurt very much */
       int need_nfds = (rfds->sds.fd_count + rfds->sds.fd_count + 
rfds->sds.fd_count > 0 ? 3 : 0)
@@ -523,8 +514,8 @@
          sock_err = efds->sds.fd_count;
        }
       break;
-#endif
     }
+#endif
   socks = sock_read + sock_write + sock_err;
 
   g_main_context_prepare (ml->gmc, &ml->max_priority);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]