gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r16542 - gnunet-gtk/src/lib
Date: Mon, 15 Aug 2011 15:18:00 +0200

Author: grothoff
Date: 2011-08-15 15:17:59 +0200 (Mon, 15 Aug 2011)
New Revision: 16542

Modified:
   gnunet-gtk/src/lib/eventloop.c
Log:
indenting

Modified: gnunet-gtk/src/lib/eventloop.c
===================================================================
--- gnunet-gtk/src/lib/eventloop.c      2011-08-15 13:16:29 UTC (rev 16541)
+++ gnunet-gtk/src/lib/eventloop.c      2011-08-15 13:17:59 UTC (rev 16542)
@@ -599,146 +599,155 @@
     }
 #else
   if (socks > 0)
-  {
-    struct timeval tvslice;
-    tvslice.tv_sec = 0;
-    tvslice.tv_usec = 0;
-    select_ret = select (max_nfds, &aread, &awrite, &aexcept, &tvslice);
-    if (select_ret == -1)
-      select_ret = 0;
+    {
+      struct timeval tvslice;
+      tvslice.tv_sec = 0;
+      tvslice.tv_usec = 0;
+      select_ret = select (max_nfds, &aread, &awrite, &aexcept, &tvslice);
+      if (select_ret == -1)
+       select_ret = 0;
 #if DEBUG_NETWORK
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "select() returned %d\n", select_ret);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+                 "select() returned %d\n", 
+                 select_ret);
 #endif
-  }
+    }
   if (always_ready_write_fd >= 0 && 
ml->cached_poll_array[always_ready_write_fd].revents & G_IO_OUT)
-  {
-    GNUNET_CONTAINER_slist_append (ml->handles_write, wfds->handles);
-    result += GNUNET_CONTAINER_slist_count (ml->handles_write);
+    {
+      GNUNET_CONTAINER_slist_append (ml->handles_write, wfds->handles);
+      result += GNUNET_CONTAINER_slist_count (ml->handles_write);
 #if DEBUG_NETWORK
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n");
 #endif
-  }
+    }
   for (i = 0; i < read_handles; i++)
-  {
-    DWORD error;
-    BOOL bret;
-    if (!(ml->cached_poll_array[i].revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)))
-      continue;
-    SetLastError (0);
-    waitstatus = 0;
-    bret = PeekNamedPipe (ml->read_array[i]->h, NULL, 0, NULL, &waitstatus, 
NULL);
-    error = GetLastError ();
+    {
+      DWORD error;
+      BOOL bret;
+      if (!(ml->cached_poll_array[i].revents & (G_IO_IN | G_IO_HUP | 
G_IO_ERR)))
+       continue;
+      SetLastError (0);
+      waitstatus = 0;
+      bret = PeekNamedPipe (ml->read_array[i]->h, NULL, 0, NULL, &waitstatus, 
NULL);
+      error = GetLastError ();
 #if DEBUG_NETWORK
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
-               "Peek at read pipe %d (0x%x) returned %d (%d bytes available) 
GLE %u\n", 
-               i, ml->read_array[i]->h, bret, waitstatus, error);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+                 "Peek at read pipe %d (0x%x) returned %d (%d bytes available) 
GLE %u\n", 
+                 i, ml->read_array[i]->h, bret, waitstatus, error);
 #endif
-    if (bret == 0 || (ml->cached_poll_array[i].revents & G_IO_ERR))
-    {
-      if (efds != NULL)
-      {
-        struct GNUNET_CONTAINER_SList_Iterator *t;
-        for (t = GNUNET_CONTAINER_slist_begin (efds->handles), i = 0;
-            GNUNET_CONTAINER_slist_end (t) != GNUNET_YES;
-            GNUNET_CONTAINER_slist_next (t), i += 1)
-        {
-          struct GNUNET_DISK_FileHandle *fh = GNUNET_CONTAINER_slist_get (t, 
NULL);
-          if (fh == ml->read_array[i])
-          {
-            GNUNET_CONTAINER_slist_add (ml->handles_except,
-                GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
-                fh, sizeof (struct GNUNET_DISK_FileHandle));
-            break;
-          }
-        }
-        GNUNET_CONTAINER_slist_iter_destroy (t);
-      }
-    }
-    else if (waitstatus <= 0)
-      continue;
-    GNUNET_CONTAINER_slist_add (ml->handles_read,
-        GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
-        ml->read_array[i], sizeof (struct GNUNET_DISK_FileHandle));
-    result += 1;
+      if (bret == 0 || (ml->cached_poll_array[i].revents & G_IO_ERR))
+       {
+         if (efds != NULL)
+           {
+             struct GNUNET_CONTAINER_SList_Iterator *t;
+             for (t = GNUNET_CONTAINER_slist_begin (efds->handles), i = 0;
+                  GNUNET_CONTAINER_slist_end (t) != GNUNET_YES;
+                  GNUNET_CONTAINER_slist_next (t), i += 1)
+               {
+                 struct GNUNET_DISK_FileHandle *fh = 
GNUNET_CONTAINER_slist_get (t, NULL);
+                 if (fh == ml->read_array[i])
+                   {
+                     GNUNET_CONTAINER_slist_add (ml->handles_except,
+                                                 
GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
+                                                 fh, sizeof (struct 
GNUNET_DISK_FileHandle));
+                     break;
+                   }
+               }
+             GNUNET_CONTAINER_slist_iter_destroy (t);
+           }
+       }
+      else if (waitstatus <= 0)
+       continue;
+      GNUNET_CONTAINER_slist_add (ml->handles_read,
+                                 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
+                                 ml->read_array[i], sizeof (struct 
GNUNET_DISK_FileHandle));
+      result += 1;
 #if DEBUG_NETWORK
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added read Pipe 0x%x (0x%x)\n", 
ml->read_array[i], ml->read_array[i]->h);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+                 "Added read Pipe 0x%x (0x%x)\n", 
+                 ml->read_array[i],
+                 ml->read_array[i]->h);
 #endif
-  }
+    }
   waitstatus = WaitForSingleObject (ml->hEventWrite, 0);
 #if DEBUG_NETWORK
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Wait for the write event returned 
%d\n", waitstatus);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Wait for the write event returned %d\n", 
+             waitstatus);
 #endif
   if (waitstatus == WAIT_OBJECT_0)
-  {
-    for (i = 0; i < wfds->sds.fd_count; i++)
     {
-      DWORD error;
-      int status;
-      int so_error = 0;
-      int sizeof_so_error = sizeof (so_error);
-      int gso_result = getsockopt (wfds->sds.fd_array[i], SOL_SOCKET, 
SO_ERROR, (char *) &so_error, &sizeof_so_error);
-      status = send (wfds->sds.fd_array[i], NULL, 0, 0);
-      error = GetLastError ();
+      for (i = 0; i < wfds->sds.fd_count; i++)
+       {
+         DWORD error;
+         int status;
+         int so_error = 0;
+         int sizeof_so_error = sizeof (so_error);
+         int gso_result = getsockopt (wfds->sds.fd_array[i], 
+                                      SOL_SOCKET, SO_ERROR,
+                                      (char *) &so_error, &sizeof_so_error);
+         status = send (wfds->sds.fd_array[i], NULL, 0, 0);
+         error = GetLastError ();
 #if DEBUG_NETWORK
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
-                 "send to the socket %d returned %d (%u)\n", 
-                 i, status, error);
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+                     "send to the socket %d returned %d (%u)\n", 
+                     i, status, error);
 #endif
-      if (status == 0
-          || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)
-          || (status == -1 && gso_result == 0 && error == WSAENOTCONN && 
so_error == WSAECONNREFUSED))
-      {
-        FD_SET (wfds->sds.fd_array[i], &awrite);
-        result += 1;
-      }
+         if (status == 0
+             || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)
+             || (status == -1 && gso_result == 0 && error == WSAENOTCONN && 
so_error == WSAECONNREFUSED))
+           {
+             FD_SET (wfds->sds.fd_array[i], &awrite);
+             result += 1;
+           }
+       }
     }
-  }
   if (rfds)
-  {
-    struct GNUNET_CONTAINER_SList_Iterator *t;
-    for (i = 0; i < rfds->sds.fd_count; i++)
-      WSAEventSelect (rfds->sds.fd_array[i], ml->hEventRead, 0);
-    for (t = GNUNET_CONTAINER_slist_begin (rfds->handles);
-        GNUNET_CONTAINER_slist_end (t) != GNUNET_YES;
-        GNUNET_CONTAINER_slist_next (t))
     {
-      struct GNUNET_DISK_FileHandle *fh = GNUNET_CONTAINER_slist_get (t, NULL);
-      if (fh->type == GNUNET_PIPE)
-        CancelIo (fh->h);
+      struct GNUNET_CONTAINER_SList_Iterator *t;
+      for (i = 0; i < rfds->sds.fd_count; i++)
+       WSAEventSelect (rfds->sds.fd_array[i], ml->hEventRead, 0);
+      for (t = GNUNET_CONTAINER_slist_begin (rfds->handles);
+          GNUNET_CONTAINER_slist_end (t) != GNUNET_YES;
+          GNUNET_CONTAINER_slist_next (t))
+       {
+         struct GNUNET_DISK_FileHandle *fh = GNUNET_CONTAINER_slist_get (t, 
NULL);
+         if (fh->type == GNUNET_PIPE)
+           CancelIo (fh->h);
+       }
+      GNUNET_CONTAINER_slist_iter_destroy (t);
+      GNUNET_NETWORK_fdset_zero (rfds);
+      if (select_ret != -1 && socks > 0)
+       GNUNET_NETWORK_fdset_copy_native (rfds, &aread, select_ret);
+      GNUNET_CONTAINER_slist_append (rfds->handles, ml->handles_read);
     }
-    GNUNET_CONTAINER_slist_iter_destroy (t);
-    GNUNET_NETWORK_fdset_zero (rfds);
-    if (select_ret != -1 && socks > 0)
-      GNUNET_NETWORK_fdset_copy_native (rfds, &aread, select_ret);
-    GNUNET_CONTAINER_slist_append (rfds->handles, ml->handles_read);
-  }
   if (wfds)
-  {
-    for (i = 0; i < wfds->sds.fd_count; i++)
-      WSAEventSelect (wfds->sds.fd_array[i], ml->hEventWrite, 0);
-    GNUNET_NETWORK_fdset_zero (wfds);
-    if (select_ret != -1 && socks > 0)
-      GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, select_ret);
-    GNUNET_CONTAINER_slist_append (wfds->handles, ml->handles_write);
-  }
+    {
+      for (i = 0; i < wfds->sds.fd_count; i++)
+       WSAEventSelect (wfds->sds.fd_array[i], ml->hEventWrite, 0);
+      GNUNET_NETWORK_fdset_zero (wfds);
+      if (select_ret != -1 && socks > 0)
+       GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, select_ret);
+      GNUNET_CONTAINER_slist_append (wfds->handles, ml->handles_write);
+    }
   if (efds)
-  {
-    for (i = 0; i < efds->sds.fd_count; i++)
-      WSAEventSelect (efds->sds.fd_array[i], ml->hEventException, 0);
-    GNUNET_NETWORK_fdset_zero (efds);
-    if (select_ret != -1 && socks > 0)
-      GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, select_ret);
-    GNUNET_CONTAINER_slist_append (efds->handles, ml->handles_except);
-    result += GNUNET_CONTAINER_slist_count (ml->handles_except);
-  }
+    {
+      for (i = 0; i < efds->sds.fd_count; i++)
+       WSAEventSelect (efds->sds.fd_array[i], ml->hEventException, 0);
+      GNUNET_NETWORK_fdset_zero (efds);
+      if (select_ret != -1 && socks > 0)
+       GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, select_ret);
+      GNUNET_CONTAINER_slist_append (efds->handles, ml->handles_except);
+      result += GNUNET_CONTAINER_slist_count (ml->handles_except);
+    }
   if (fd_counter > 0)
     /* This is not accurate (select_ret counts write-ready sockets,
      * and result does as well. Anything out there actually cares
      * about this?
      */
-    return select_ret + result;
+    result = select_ret + result;
   else
-    return 0;
+    result = 0;
 #endif
   return result;
 }




reply via email to

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