aboutsummaryrefslogtreecommitdiff
path: root/src/lib/eventloop.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 12:40:32 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 12:40:32 +0000
commit0c54b55429d30d798657643408bfe8893848b080 (patch)
treef79d1cd4ef509b082eb96b92d7822cad633e9fc5 /src/lib/eventloop.c
parent72ff85451763c110eef7da0ac845a972c5e5808d (diff)
downloadgnunet-gtk-0c54b55429d30d798657643408bfe8893848b080.tar.gz
gnunet-gtk-0c54b55429d30d798657643408bfe8893848b080.zip
some code cleanup
Diffstat (limited to 'src/lib/eventloop.c')
-rw-r--r--src/lib/eventloop.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c
index a164e306..295a60bb 100644
--- a/src/lib/eventloop.c
+++ b/src/lib/eventloop.c
@@ -319,39 +319,30 @@ gnunet_gtk_select (void *cls,
319 if (ml->cached_poll_array_size == 0) 319 if (ml->cached_poll_array_size == 0)
320 resize_cached_poll_array (ml, INITIAL_POLL_ARRAY_SIZE); 320 resize_cached_poll_array (ml, INITIAL_POLL_ARRAY_SIZE);
321 321
322 while (1) 322 fd_counter = 0;
323 {
324 fd_counter = 0;
325#if !WINDOWS 323#if !WINDOWS
326 gboolean need_realloc = FALSE; 324 for (i = 0; i < max_nfds; i += 1)
327 for (i = 0; !need_realloc && i < max_nfds; i += 1) 325 {
328 { 326 int isset[3];
329 int isset[3];
330 327
331 isset[0] = (rfds == NULL) ? 0 : FD_ISSET (i, &rfds->sds); 328 isset[0] = (rfds == NULL) ? 0 : FD_ISSET (i, &rfds->sds);
332 isset[1] = (wfds == NULL) ? 0 : FD_ISSET (i, &wfds->sds); 329 isset[1] = (wfds == NULL) ? 0 : FD_ISSET (i, &wfds->sds);
333 isset[2] = (efds == NULL) ? 0 : FD_ISSET (i, &efds->sds); 330 isset[2] = (efds == NULL) ? 0 : FD_ISSET (i, &efds->sds);
334 if (!isset[0] && !isset[1] && !isset[2]) 331 if ((! isset[0]) && (! isset[1]) && (! isset[2]))
335 continue; 332 continue;
336 if (fd_counter >= ml->cached_poll_array_size) 333 if (fd_counter >= ml->cached_poll_array_size)
337 { 334 resize_cached_poll_array (ml, ml->cached_poll_array_size * 2);
338 need_realloc = TRUE; 335 ml->cached_poll_array[fd_counter].fd = i;
339 break; 336 ml->cached_poll_array[fd_counter].events
340 } 337 = (isset[0] ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0)
341 ml->cached_poll_array[fd_counter].fd = i; 338 | (isset[1] ? G_IO_OUT | G_IO_ERR : 0)
342 ml->cached_poll_array[fd_counter].events = (isset[0] ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0) 339 | (isset[2] ? G_IO_ERR : 0);
343 | (isset[1] ? G_IO_OUT | G_IO_ERR : 0) | (isset[2] ? G_IO_ERR : 0); 340 fd_counter++;
344 fd_counter++; 341 }
345 }
346 if (need_realloc)
347 {
348 resize_cached_poll_array (ml, ml->cached_poll_array_size * 2);
349 fd_counter = 0;
350 need_realloc = FALSE;
351 }
352 else
353 break;
354#else 342#else
343 while (1)
344 {
345 fd_counter = 0;
355 struct GNUNET_CONTAINER_SList_Iterator *t; 346 struct GNUNET_CONTAINER_SList_Iterator *t;
356 /* We might overshoot a little, but that won't hurt very much */ 347 /* We might overshoot a little, but that won't hurt very much */
357 int need_nfds = (rfds->sds.fd_count + rfds->sds.fd_count + rfds->sds.fd_count > 0 ? 3 : 0) 348 int need_nfds = (rfds->sds.fd_count + rfds->sds.fd_count + rfds->sds.fd_count > 0 ? 3 : 0)
@@ -523,8 +514,8 @@ gnunet_gtk_select (void *cls,
523 sock_err = efds->sds.fd_count; 514 sock_err = efds->sds.fd_count;
524 } 515 }
525 break; 516 break;
526#endif
527 } 517 }
518#endif
528 socks = sock_read + sock_write + sock_err; 519 socks = sock_read + sock_write + sock_err;
529 520
530 g_main_context_prepare (ml->gmc, &ml->max_priority); 521 g_main_context_prepare (ml->gmc, &ml->max_priority);