[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16524 - gnunet-gtk/src/lib
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16524 - gnunet-gtk/src/lib |
Date: |
Mon, 15 Aug 2011 14:32:00 +0200 |
Author: grothoff
Date: 2011-08-15 14:31:59 +0200 (Mon, 15 Aug 2011)
New Revision: 16524
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 12:30:49 UTC (rev 16523)
+++ gnunet-gtk/src/lib/eventloop.c 2011-08-15 12:31:59 UTC (rev 16524)
@@ -323,192 +323,192 @@
gboolean need_realloc = FALSE;
for (i = 0; !need_realloc && 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 += 1;
- }
- if (need_realloc)
- {
- resize_cached_poll_array (ml, ml->cached_poll_array_size * 2);
- fd_counter = 0;
- need_realloc = FALSE;
- }
- else
- break;
+ 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 += 1;
+ }
+ if (need_realloc)
+ {
+ resize_cached_poll_array (ml, ml->cached_poll_array_size * 2);
+ fd_counter = 0;
+ need_realloc = FALSE;
+ }
+ else
+ break;
#else
- 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)
+ 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)
+ (rfds == NULL ? 0 : GNUNET_CONTAINER_slist_count (rfds->handles))
+ (wfds == NULL ? 0 : 1)
+ 1;
- if (need_nfds >= ml->cached_poll_array_size)
- {
- /* Since there are also gmainloop's own fds, just need_nfds won't be
- * enough, so make it twice as long.
- */
- ml->cached_poll_array = ml->cached_poll_array = g_renew (GPollFD,
ml->cached_poll_array, need_nfds * 2);
- ml->cached_poll_array_size = ml->cached_poll_array_size = need_nfds * 2;
- }
- if (ml->read_array_length < GNUNET_CONTAINER_slist_count (rfds->handles))
- {
- ml->read_array = GNUNET_realloc (ml->read_array,
GNUNET_CONTAINER_slist_count (rfds->handles) * sizeof (struct
GNUNET_DISK_FileHandle *));
- ml->read_array_length = GNUNET_CONTAINER_slist_count (rfds->handles);
- }
- if (rfds != NULL)
- {
- for (t = GNUNET_CONTAINER_slist_begin (rfds->handles), i = 0;
- GNUNET_CONTAINER_slist_end (t) != GNUNET_YES;
- GNUNET_CONTAINER_slist_next (t), i += 1)
- {
- struct GNUNET_DISK_FileHandle *fh;
- fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (t,
NULL);
- if (fh->type == GNUNET_PIPE)
- {
- if (!ReadFile (fh->h, NULL, 0, NULL, fh->oOverlapRead))
- {
- DWORD error_code = GetLastError();
- if (error_code == ERROR_IO_PENDING)
- {
+ if (need_nfds >= ml->cached_poll_array_size)
+ {
+ /* Since there are also gmainloop's own fds, just need_nfds won't be
+ * enough, so make it twice as long.
+ */
+ ml->cached_poll_array = ml->cached_poll_array = g_renew (GPollFD,
ml->cached_poll_array, need_nfds * 2);
+ ml->cached_poll_array_size = ml->cached_poll_array_size = need_nfds *
2;
+ }
+ if (ml->read_array_length < GNUNET_CONTAINER_slist_count (rfds->handles))
+ {
+ ml->read_array = GNUNET_realloc (ml->read_array,
GNUNET_CONTAINER_slist_count (rfds->handles) * sizeof (struct
GNUNET_DISK_FileHandle *));
+ ml->read_array_length = GNUNET_CONTAINER_slist_count (rfds->handles);
+ }
+ if (rfds != NULL)
+ {
+ for (t = GNUNET_CONTAINER_slist_begin (rfds->handles), i = 0;
+ GNUNET_CONTAINER_slist_end (t) != GNUNET_YES;
+ GNUNET_CONTAINER_slist_next (t), i += 1)
+ {
+ struct GNUNET_DISK_FileHandle *fh;
+ fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get
(t, NULL);
+ if (fh->type == GNUNET_PIPE)
+ {
+ if (!ReadFile (fh->h, NULL, 0, NULL, fh->oOverlapRead))
+ {
+ DWORD error_code = GetLastError();
+ if (error_code == ERROR_IO_PENDING)
+ {
#if DEBUG_NETWORK
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the pipe's 0x%x
overlapped event to the array as %d\n", fh->h, nhandles);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the
pipe's 0x%x overlapped event to the array as %d\n", fh->h, nhandles);
#endif
- ml->cached_poll_array[fd_counter].fd = (intptr_t)
fh->oOverlapRead->hEvent;
- /* On W32 .events makes no sense - g_poll will just OR its
- * contents into .revents when the .fd event fires.
- * So we'll use it in the way that suits us the best.
- */
- ml->cached_poll_array[fd_counter].events = G_IO_IN;
- fd_counter += 1;
- ml->read_array[read_handles] = fh;
- read_handles += 1;
- }
- else
- {
- ml->cached_poll_array[fd_counter].fd = (intptr_t)
ml->hEventReadReady;
- ml->cached_poll_array[fd_counter].events = G_IO_HUP;
- fd_counter += 1;
- ml->read_array[read_handles] = fh;
- read_handles += 1;
- }
- }
- else
- {
+ ml->cached_poll_array[fd_counter].fd = (intptr_t)
fh->oOverlapRead->hEvent;
+ /* On W32 .events makes no sense - g_poll will just
OR its
+ * contents into .revents when the .fd event fires.
+ * So we'll use it in the way that suits us the best.
+ */
+ ml->cached_poll_array[fd_counter].events = G_IO_IN;
+ fd_counter += 1;
+ ml->read_array[read_handles] = fh;
+ read_handles += 1;
+ }
+ else
+ {
+ ml->cached_poll_array[fd_counter].fd = (intptr_t)
ml->hEventReadReady;
+ ml->cached_poll_array[fd_counter].events = G_IO_HUP;
+ fd_counter += 1;
+ ml->read_array[read_handles] = fh;
+ read_handles += 1;
+ }
+ }
+ else
+ {
#if DEBUG_NETWORK
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the read ready event
to the array as %d\n", nhandles);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the read
ready event to the array as %d\n", nhandles);
#endif
- ml->cached_poll_array[fd_counter].fd = (intptr_t)
ml->hEventReadReady;
- ml->cached_poll_array[fd_counter].events = G_IO_IN;
- fd_counter += 1;
- ml->read_array[read_handles] = fh;
- read_handles += 1;
- }
- }
- else
- {
- GNUNET_CONTAINER_slist_add (ml->handles_read,
- GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
- fh, sizeof (struct GNUNET_DISK_FileHandle));
- pre_ret += 1;
- }
- }
- }
- if (wfds != NULL && GNUNET_CONTAINER_slist_count (wfds->handles) > 0)
- {
- ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventPipeWrite;
- ml->cached_poll_array[fd_counter].events = G_IO_OUT;
- always_ready_write_fd = fd_counter;
- fd_counter += 1;
- }
- if (efds != NULL)
- {
- 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;
- DWORD dwBytes;
- fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (t,
NULL);
- if (fh->type == GNUNET_PIPE)
- {
- if (!PeekNamedPipe (fh->h, NULL, 0, NULL, &dwBytes, NULL))
- {
- GNUNET_CONTAINER_slist_add (ml->handles_except,
- GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
- fh, sizeof (struct GNUNET_DISK_FileHandle));
- pre_ret += 1;
- }
- }
- }
- }
- GNUNET_CONTAINER_slist_iter_destroy (t);
-
- if (rfds != NULL && rfds->sds.fd_count > 0)
- {
+ ml->cached_poll_array[fd_counter].fd = (intptr_t)
ml->hEventReadReady;
+ ml->cached_poll_array[fd_counter].events = G_IO_IN;
+ fd_counter += 1;
+ ml->read_array[read_handles] = fh;
+ read_handles += 1;
+ }
+ }
+ else
+ {
+ GNUNET_CONTAINER_slist_add (ml->handles_read,
+
GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
+ fh, sizeof (struct
GNUNET_DISK_FileHandle));
+ pre_ret += 1;
+ }
+ }
+ }
+ if (wfds != NULL && GNUNET_CONTAINER_slist_count (wfds->handles) > 0)
+ {
+ ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventPipeWrite;
+ ml->cached_poll_array[fd_counter].events = G_IO_OUT;
+ always_ready_write_fd = fd_counter;
+ fd_counter += 1;
+ }
+ if (efds != NULL)
+ {
+ 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;
+ DWORD dwBytes;
+ fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get
(t, NULL);
+ if (fh->type == GNUNET_PIPE)
+ {
+ if (!PeekNamedPipe (fh->h, NULL, 0, NULL, &dwBytes, NULL))
+ {
+ GNUNET_CONTAINER_slist_add (ml->handles_except,
+
GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
+ fh, sizeof (struct
GNUNET_DISK_FileHandle));
+ pre_ret += 1;
+ }
+ }
+ }
+ }
+ GNUNET_CONTAINER_slist_iter_destroy (t);
+
+ if (rfds != NULL && rfds->sds.fd_count > 0)
+ {
#if DEBUG_NETWORK
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the socket read event to
the array as %d\n", fd_counter);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the socket read event to
the array as %d\n", fd_counter);
#endif
- ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventRead;
- ml->cached_poll_array[fd_counter].events = G_IO_IN;
- for (i = 0; i < rfds->sds.fd_count; i++)
- WSAEventSelect (rfds->sds.fd_array[i], ml->hEventRead, FD_ACCEPT |
FD_READ | FD_CLOSE);
- fd_counter += 1;
- sock_read = rfds->sds.fd_count;
- }
- if (wfds != NULL && wfds->sds.fd_count > 0)
- {
- int wakeup = 0;
+ ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventRead;
+ ml->cached_poll_array[fd_counter].events = G_IO_IN;
+ for (i = 0; i < rfds->sds.fd_count; i++)
+ WSAEventSelect (rfds->sds.fd_array[i], ml->hEventRead, FD_ACCEPT |
FD_READ | FD_CLOSE);
+ fd_counter += 1;
+ sock_read = rfds->sds.fd_count;
+ }
+ if (wfds != NULL && wfds->sds.fd_count > 0)
+ {
+ int wakeup = 0;
#if DEBUG_NETWORK
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the socket write event to
the array as %d\n", fd_counter);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the socket write event
to the array as %d\n", fd_counter);
#endif
- ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventWrite;
- ml->cached_poll_array[fd_counter].events = G_IO_OUT;
- for (i = 0; i < wfds->sds.fd_count; i++)
- {
- DWORD error;
- int status;
- status = send (wfds->sds.fd_array[i], NULL, 0, 0);
- error = GetLastError ();
+ ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventWrite;
+ ml->cached_poll_array[fd_counter].events = G_IO_OUT;
+ for (i = 0; i < wfds->sds.fd_count; i++)
+ {
+ DWORD error;
+ int status;
+ status = send (wfds->sds.fd_array[i], NULL, 0, 0);
+ error = GetLastError ();
#if DEBUG_NETWORK
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "pre-send to the socket %d
returned %d (%u)\n", i, status, error);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "pre-send to the socket %d
returned %d (%u)\n", i, status, error);
#endif
- if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN))
- wakeup = 1;
- WSAEventSelect (wfds->sds.fd_array[i], ml->hEventWrite, FD_WRITE |
FD_CONNECT | FD_CLOSE);
- }
- if (wakeup)
- SetEvent (ml->hEventWrite);
- fd_counter += 1;
- sock_write = wfds->sds.fd_count;
- }
- if (efds != NULL && efds->sds.fd_count > 0)
- {
+ if (status == 0 || (error != WSAEWOULDBLOCK && error !=
WSAENOTCONN))
+ wakeup = 1;
+ WSAEventSelect (wfds->sds.fd_array[i], ml->hEventWrite, FD_WRITE
| FD_CONNECT | FD_CLOSE);
+ }
+ if (wakeup)
+ SetEvent (ml->hEventWrite);
+ fd_counter += 1;
+ sock_write = wfds->sds.fd_count;
+ }
+ if (efds != NULL && efds->sds.fd_count > 0)
+ {
#if DEBUG_NETWORK
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the socket error event to
the array as %d\n", fd_counter);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the socket error event
to the array as %d\n", fd_counter);
#endif
- ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventException;
- ml->cached_poll_array[fd_counter].events = G_IO_ERR;
- for (i = 0; i < efds->sds.fd_count; i++)
- WSAEventSelect (efds->sds.fd_array[i], ml->hEventException, FD_OOB |
FD_CLOSE);
- fd_counter += 1;
- sock_err = efds->sds.fd_count;
+ ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventException;
+ ml->cached_poll_array[fd_counter].events = G_IO_ERR;
+ for (i = 0; i < efds->sds.fd_count; i++)
+ WSAEventSelect (efds->sds.fd_array[i], ml->hEventException, FD_OOB
| FD_CLOSE);
+ fd_counter += 1;
+ sock_err = efds->sds.fd_count;
+ }
+ break;
+#endif
}
- break;
-#endif
- }
socks = sock_read + sock_write + sock_err;
g_main_context_prepare (ml->gmc, &ml->max_priority);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16524 - gnunet-gtk/src/lib,
gnunet <=