diff options
Diffstat (limited to 'src/lib/eventloop.c')
-rw-r--r-- | src/lib/eventloop.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/lib/eventloop.c b/src/lib/eventloop.c index 36367f00..8f891dc1 100644 --- a/src/lib/eventloop.c +++ b/src/lib/eventloop.c | |||
@@ -223,7 +223,7 @@ static void | |||
223 | resize_cached_poll_array (struct GNUNET_GTK_MainLoop *ml, | 223 | resize_cached_poll_array (struct GNUNET_GTK_MainLoop *ml, |
224 | guint new_size) | 224 | guint new_size) |
225 | { | 225 | { |
226 | ml->cached_poll_array = g_new (GPollFD, new_size); | 226 | ml->cached_poll_array = g_renew (GPollFD, ml->cached_poll_array, new_size); |
227 | ml->cached_poll_array_size = new_size; | 227 | ml->cached_poll_array_size = new_size; |
228 | } | 228 | } |
229 | 229 | ||
@@ -338,7 +338,7 @@ gnunet_gtk_select (void *cls, | |||
338 | ml->cached_poll_array[fd_counter].fd = i; | 338 | ml->cached_poll_array[fd_counter].fd = i; |
339 | ml->cached_poll_array[fd_counter].events = (isset[0] ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0) | 339 | ml->cached_poll_array[fd_counter].events = (isset[0] ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0) |
340 | | (isset[1] ? G_IO_OUT | G_IO_ERR : 0) | (isset[2] ? G_IO_ERR : 0); | 340 | | (isset[1] ? G_IO_OUT | G_IO_ERR : 0) | (isset[2] ? G_IO_ERR : 0); |
341 | fd_counter += 1; | 341 | fd_counter++; |
342 | } | 342 | } |
343 | if (need_realloc) | 343 | if (need_realloc) |
344 | { | 344 | { |
@@ -365,7 +365,8 @@ gnunet_gtk_select (void *cls, | |||
365 | } | 365 | } |
366 | if (ml->read_array_length < GNUNET_CONTAINER_slist_count (rfds->handles)) | 366 | if (ml->read_array_length < GNUNET_CONTAINER_slist_count (rfds->handles)) |
367 | { | 367 | { |
368 | ml->read_array = GNUNET_realloc (ml->read_array, GNUNET_CONTAINER_slist_count (rfds->handles) * sizeof (struct GNUNET_DISK_FileHandle *)); | 368 | ml->read_array = GNUNET_realloc (ml->read_array, |
369 | GNUNET_CONTAINER_slist_count (rfds->handles) * sizeof (struct GNUNET_DISK_FileHandle *)); | ||
369 | ml->read_array_length = GNUNET_CONTAINER_slist_count (rfds->handles); | 370 | ml->read_array_length = GNUNET_CONTAINER_slist_count (rfds->handles); |
370 | } | 371 | } |
371 | if (rfds != NULL) | 372 | if (rfds != NULL) |
@@ -384,7 +385,9 @@ gnunet_gtk_select (void *cls, | |||
384 | if (error_code == ERROR_IO_PENDING) | 385 | if (error_code == ERROR_IO_PENDING) |
385 | { | 386 | { |
386 | #if DEBUG_NETWORK | 387 | #if DEBUG_NETWORK |
387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the pipe's 0x%x overlapped event to the array as %d\n", fh->h, nhandles); | 388 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
389 | "Adding the pipe's 0x%x overlapped event to the array as %d\n", | ||
390 | fh->h, nhandles); | ||
388 | #endif | 391 | #endif |
389 | ml->cached_poll_array[fd_counter].fd = (intptr_t) fh->oOverlapRead->hEvent; | 392 | ml->cached_poll_array[fd_counter].fd = (intptr_t) fh->oOverlapRead->hEvent; |
390 | /* On W32 .events makes no sense - g_poll will just OR its | 393 | /* On W32 .events makes no sense - g_poll will just OR its |
@@ -408,7 +411,9 @@ gnunet_gtk_select (void *cls, | |||
408 | else | 411 | else |
409 | { | 412 | { |
410 | #if DEBUG_NETWORK | 413 | #if DEBUG_NETWORK |
411 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the read ready event to the array as %d\n", nhandles); | 414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
415 | "Adding the read ready event to the array as %d\n", | ||
416 | nhandles); | ||
412 | #endif | 417 | #endif |
413 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventReadReady; | 418 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventReadReady; |
414 | ml->cached_poll_array[fd_counter].events = G_IO_IN; | 419 | ml->cached_poll_array[fd_counter].events = G_IO_IN; |
@@ -459,7 +464,9 @@ gnunet_gtk_select (void *cls, | |||
459 | if (rfds != NULL && rfds->sds.fd_count > 0) | 464 | if (rfds != NULL && rfds->sds.fd_count > 0) |
460 | { | 465 | { |
461 | #if DEBUG_NETWORK | 466 | #if DEBUG_NETWORK |
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the socket read event to the array as %d\n", fd_counter); | 467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
468 | "Adding the socket read event to the array as %d\n", | ||
469 | fd_counter); | ||
463 | #endif | 470 | #endif |
464 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventRead; | 471 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventRead; |
465 | ml->cached_poll_array[fd_counter].events = G_IO_IN; | 472 | ml->cached_poll_array[fd_counter].events = G_IO_IN; |
@@ -472,7 +479,9 @@ gnunet_gtk_select (void *cls, | |||
472 | { | 479 | { |
473 | int wakeup = 0; | 480 | int wakeup = 0; |
474 | #if DEBUG_NETWORK | 481 | #if DEBUG_NETWORK |
475 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the socket write event to the array as %d\n", fd_counter); | 482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
483 | "Adding the socket write event to the array as %d\n", | ||
484 | fd_counter); | ||
476 | #endif | 485 | #endif |
477 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventWrite; | 486 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventWrite; |
478 | ml->cached_poll_array[fd_counter].events = G_IO_OUT; | 487 | ml->cached_poll_array[fd_counter].events = G_IO_OUT; |
@@ -483,7 +492,9 @@ gnunet_gtk_select (void *cls, | |||
483 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); | 492 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); |
484 | error = GetLastError (); | 493 | error = GetLastError (); |
485 | #if DEBUG_NETWORK | 494 | #if DEBUG_NETWORK |
486 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "pre-send to the socket %d returned %d (%u)\n", i, status, error); | 495 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
496 | "pre-send to the socket %d returned %d (%u)\n", | ||
497 | i, status, error); | ||
487 | #endif | 498 | #endif |
488 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)) | 499 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)) |
489 | wakeup = 1; | 500 | wakeup = 1; |
@@ -497,7 +508,9 @@ gnunet_gtk_select (void *cls, | |||
497 | if (efds != NULL && efds->sds.fd_count > 0) | 508 | if (efds != NULL && efds->sds.fd_count > 0) |
498 | { | 509 | { |
499 | #if DEBUG_NETWORK | 510 | #if DEBUG_NETWORK |
500 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding the socket error event to the array as %d\n", fd_counter); | 511 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
512 | "Adding the socket error event to the array as %d\n", | ||
513 | fd_counter); | ||
501 | #endif | 514 | #endif |
502 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventException; | 515 | ml->cached_poll_array[fd_counter].fd = (intptr_t) ml->hEventException; |
503 | ml->cached_poll_array[fd_counter].events = G_IO_ERR; | 516 | ml->cached_poll_array[fd_counter].events = G_IO_ERR; |
@@ -530,19 +543,25 @@ gnunet_gtk_select (void *cls, | |||
530 | if (pre_ret > 0) | 543 | if (pre_ret > 0) |
531 | { | 544 | { |
532 | #if DEBUG_NETWORK | 545 | #if DEBUG_NETWORK |
533 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "pre_ret is %d, setting delay to 0\n", pre_ret); | 546 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
547 | "pre_ret is %d, setting delay to 0\n", | ||
548 | pre_ret); | ||
534 | #endif | 549 | #endif |
535 | delay = 0; | 550 | delay = 0; |
536 | } | 551 | } |
537 | 552 | ||
538 | #if DEBUG_NETWORK | 553 | #if DEBUG_NETWORK |
539 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "We have %d of our FDs and %d of GMC ones, going to wait %6dms\n", fd_counter, need_gfds, delay); | 554 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
555 | "We have %d of our FDs and %d of GMC ones, going to wait %6dms\n", | ||
556 | fd_counter, need_gfds, delay); | ||
540 | #endif | 557 | #endif |
541 | 558 | ||
542 | poll_result = g_poll (ml->cached_poll_array, fd_counter + need_gfds, delay); | 559 | poll_result = g_poll (ml->cached_poll_array, fd_counter + need_gfds, delay); |
543 | 560 | ||
544 | #if DEBUG_NETWORK | 561 | #if DEBUG_NETWORK |
545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "g_poll returned : %d\n", poll_result); | 562 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
563 | "g_poll returned : %d\n", | ||
564 | poll_result); | ||
546 | #endif | 565 | #endif |
547 | 566 | ||
548 | /* Take care of GUI events. | 567 | /* Take care of GUI events. |