diff options
author | LRN <lrn1986@gmail.com> | 2013-12-19 18:39:12 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2013-12-19 18:39:12 +0000 |
commit | 2304992a15f66518c75e440d53f0b555027c1d96 (patch) | |
tree | 3df085fa76340a0c6d3f500f8648f6a5b884290e /src | |
parent | bbfebd03c83c09915c23470944533c8d6c611a1e (diff) | |
download | gnunet-2304992a15f66518c75e440d53f0b555027c1d96.tar.gz gnunet-2304992a15f66518c75e440d53f0b555027c1d96.zip |
Increase NSP debug logging verbosity greatly
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/w32nsp.c | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/src/gns/w32nsp.c b/src/gns/w32nsp.c index 9737c7502..2b93df848 100644 --- a/src/gns/w32nsp.c +++ b/src/gns/w32nsp.c | |||
@@ -428,34 +428,32 @@ GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | |||
428 | effective_flags = dwControlFlags & records[rec].flags; | 428 | effective_flags = dwControlFlags & records[rec].flags; |
429 | if (records[rec].buf) | 429 | if (records[rec].buf) |
430 | { | 430 | { |
431 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: checking buffer\n"); | ||
431 | header = *((struct GNUNET_MessageHeader *) records[rec].buf); | 432 | header = *((struct GNUNET_MessageHeader *) records[rec].buf); |
432 | if (dwControlFlags & LUP_FLUSHCACHE) | 433 | if (*lpdwBufferLength < header.size - sizeof (struct GNUNET_W32RESOLVER_GetMessage)) |
433 | { | 434 | { |
434 | free (records[rec].buf); | 435 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: client buffer is too small\n"); |
435 | records[rec].buf = NULL; | 436 | SetLastError (WSAEFAULT); |
436 | } | ||
437 | else | ||
438 | { | ||
439 | if (*lpdwBufferLength < header.size - sizeof (struct GNUNET_W32RESOLVER_GetMessage)) | ||
440 | { | ||
441 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: client buffer is too small\n"); | ||
442 | SetLastError (WSAEFAULT); | ||
443 | //LeaveCriticalSection (&records_cs); | ||
444 | return SOCKET_ERROR; | ||
445 | } | ||
446 | memcpy (lpqsResults, &((struct GNUNET_W32RESOLVER_GetMessage *)records[rec].buf)[1], header.size - sizeof (struct GNUNET_W32RESOLVER_GetMessage)); | ||
447 | free (records[rec].buf); | ||
448 | records[rec].buf = NULL; | ||
449 | //LeaveCriticalSection (&records_cs); | 437 | //LeaveCriticalSection (&records_cs); |
450 | UnmarshallWSAQUERYSETW ((LPWSAQUERYSETW) lpqsResults); | 438 | return SOCKET_ERROR; |
451 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: OK (from buffer)\n"); | ||
452 | return NO_ERROR; | ||
453 | } | 439 | } |
440 | memcpy (lpqsResults, &((struct GNUNET_W32RESOLVER_GetMessage *)records[rec].buf)[1], header.size - sizeof (struct GNUNET_W32RESOLVER_GetMessage)); | ||
441 | free (records[rec].buf); | ||
442 | records[rec].buf = NULL; | ||
443 | //LeaveCriticalSection (&records_cs); | ||
444 | UnmarshallWSAQUERYSETW ((LPWSAQUERYSETW) lpqsResults); | ||
445 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: OK (from buffer)\n"); | ||
446 | return NO_ERROR; | ||
454 | } | 447 | } |
455 | records[rec].state |= 8; | 448 | records[rec].state |= 8; |
456 | //LeaveCriticalSection (&records_cs); | 449 | //LeaveCriticalSection (&records_cs); |
457 | to_receive = sizeof (header); | 450 | to_receive = sizeof (header); |
458 | rc = 0; | 451 | rc = 0; |
452 | { | ||
453 | unsigned long have; | ||
454 | int ior = ioctlsocket ((SOCKET) hLookup, FIONREAD, &have); | ||
455 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: reading %d bytes as a header from %p, %lu bytes available\n", to_receive, hLookup, have); | ||
456 | } | ||
459 | while (to_receive > 0) | 457 | while (to_receive > 0) |
460 | { | 458 | { |
461 | t = recv ((SOCKET) hLookup, &((char *) &header)[rc], to_receive, 0); | 459 | t = recv ((SOCKET) hLookup, &((char *) &header)[rc], to_receive, 0); |
@@ -467,6 +465,11 @@ GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | |||
467 | else | 465 | else |
468 | break; | 466 | break; |
469 | } | 467 | } |
468 | { | ||
469 | unsigned long have; | ||
470 | int ior = ioctlsocket ((SOCKET) hLookup, FIONREAD, &have); | ||
471 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: read %d bytes as a header from %p, %lu bytes available\n", rc, hLookup, have); | ||
472 | } | ||
470 | //EnterCriticalSection (&records_cs); | 473 | //EnterCriticalSection (&records_cs); |
471 | records[rec].state &= ~8; | 474 | records[rec].state &= ~8; |
472 | if (rc != sizeof (header)) | 475 | if (rc != sizeof (header)) |
@@ -478,7 +481,7 @@ GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | |||
478 | } | 481 | } |
479 | else | 482 | else |
480 | { | 483 | { |
481 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: failed to receive enough data\n"); | 484 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: failed to receive enough data for a header (rc %d != %u, state is 0x%0X)\n", rc, sizeof (header), records[rec].state); |
482 | SetLastError (WSA_E_NO_MORE); | 485 | SetLastError (WSA_E_NO_MORE); |
483 | } | 486 | } |
484 | records[rec].state |= 4; | 487 | records[rec].state |= 4; |
@@ -488,12 +491,16 @@ GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | |||
488 | records[rec].state &= ~8; | 491 | records[rec].state &= ~8; |
489 | header.type = ntohs (header.type); | 492 | header.type = ntohs (header.type); |
490 | header.size = ntohs (header.size); | 493 | header.size = ntohs (header.size); |
494 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: header type %d, header size %u\n", header.type, header.size); | ||
491 | if (header.type != GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE || | 495 | if (header.type != GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE || |
492 | (header.type == GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE && | 496 | (header.type == GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE && |
493 | header.size == sizeof (header))) | 497 | header.size == sizeof (header))) |
494 | { | 498 | { |
495 | records[rec].state |= 4; | 499 | records[rec].state |= 4; |
496 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: header is wrong or type is wrong or no data\n"); | 500 | if (header.type != GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE) |
501 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: header type is wrong\n"); | ||
502 | else | ||
503 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: empty header - no data\n"); | ||
497 | //LeaveCriticalSection (&records_cs); | 504 | //LeaveCriticalSection (&records_cs); |
498 | SetLastError (WSA_E_NO_MORE); | 505 | SetLastError (WSA_E_NO_MORE); |
499 | return SOCKET_ERROR; | 506 | return SOCKET_ERROR; |
@@ -512,9 +519,16 @@ GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | |||
512 | memcpy (buf, &header, sizeof (header)); | 519 | memcpy (buf, &header, sizeof (header)); |
513 | to_receive = header.size - sizeof (header); | 520 | to_receive = header.size - sizeof (header); |
514 | rc = 0; | 521 | rc = 0; |
522 | { | ||
523 | unsigned long have; | ||
524 | int ior = ioctlsocket ((SOCKET) hLookup, FIONREAD, &have); | ||
525 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: reading %d bytes as a body from %p, %lu bytes available\n", to_receive, hLookup, have); | ||
526 | } | ||
515 | while (to_receive > 0) | 527 | while (to_receive > 0) |
516 | { | 528 | { |
529 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: recv (%d)\n", to_receive); | ||
517 | t = recv ((SOCKET) hLookup, &((char *) &((struct GNUNET_MessageHeader *) buf)[1])[rc], to_receive, 0); | 530 | t = recv ((SOCKET) hLookup, &((char *) &((struct GNUNET_MessageHeader *) buf)[1])[rc], to_receive, 0); |
531 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: recv returned %d\n", t); | ||
518 | if (t > 0) | 532 | if (t > 0) |
519 | { | 533 | { |
520 | rc += t; | 534 | rc += t; |
@@ -523,6 +537,11 @@ GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | |||
523 | else | 537 | else |
524 | break; | 538 | break; |
525 | } | 539 | } |
540 | { | ||
541 | unsigned long have; | ||
542 | int ior = ioctlsocket ((SOCKET) hLookup, FIONREAD, &have); | ||
543 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: read %d bytes as a body from %p, %lu bytes available\n", rc, hLookup, have); | ||
544 | } | ||
526 | //EnterCriticalSection (&records_cs); | 545 | //EnterCriticalSection (&records_cs); |
527 | records[rec].state &= ~8; | 546 | records[rec].state &= ~8; |
528 | if (rc != header.size - sizeof (header)) | 547 | if (rc != header.size - sizeof (header)) |
@@ -535,7 +554,7 @@ GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | |||
535 | } | 554 | } |
536 | else | 555 | else |
537 | { | 556 | { |
538 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: failed to receive enough data\n"); | 557 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: failed to receive enough data for the rest (rc %d != %d, state is 0x%0X)\n", rc, header.size - sizeof (header), records[rec].state); |
539 | SetLastError (WSA_E_NO_MORE); | 558 | SetLastError (WSA_E_NO_MORE); |
540 | } | 559 | } |
541 | records[rec].state |= 4; | 560 | records[rec].state |= 4; |
@@ -551,6 +570,7 @@ GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | |||
551 | return SOCKET_ERROR; | 570 | return SOCKET_ERROR; |
552 | } | 571 | } |
553 | //LeaveCriticalSection (&records_cs); | 572 | //LeaveCriticalSection (&records_cs); |
573 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: writing %d bytes into result buffer\n", header.size - sizeof (struct GNUNET_W32RESOLVER_GetMessage)); | ||
554 | memcpy (lpqsResults, &((struct GNUNET_W32RESOLVER_GetMessage *)buf)[1], header.size - sizeof (struct GNUNET_W32RESOLVER_GetMessage)); | 574 | memcpy (lpqsResults, &((struct GNUNET_W32RESOLVER_GetMessage *)buf)[1], header.size - sizeof (struct GNUNET_W32RESOLVER_GetMessage)); |
555 | free (buf); | 575 | free (buf); |
556 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: OK\n"); | 576 | DEBUGLOG ("GNUNET_W32NSP_LookupServiceNext: OK\n"); |