diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-02-26 14:21:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-02-26 14:21:49 +0000 |
commit | 34961f382d98822d1fa3506e8bfdf163e2e915ea (patch) | |
tree | 855ac5770b741da80fc8c2fff1bfb283913e9685 /src/util/network.c | |
parent | 3d97cc0d1b93fd0ee2deb2440b3c3a59bfa506ed (diff) | |
download | gnunet-34961f382d98822d1fa3506e8bfdf163e2e915ea.tar.gz gnunet-34961f382d98822d1fa3506e8bfdf163e2e915ea.zip |
-some more #if DEBUG elimination
Diffstat (limited to 'src/util/network.c')
-rw-r--r-- | src/util/network.c | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/util/network.c b/src/util/network.c index fb8744af1..e530ab743 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -35,7 +35,6 @@ | |||
35 | 35 | ||
36 | #define DEBUG_NETWORK GNUNET_EXTRA_LOGGING | 36 | #define DEBUG_NETWORK GNUNET_EXTRA_LOGGING |
37 | 37 | ||
38 | #define DEBUG_W32_CYCLES GNUNET_EXTRA_LOGGING | ||
39 | 38 | ||
40 | #ifndef INVALID_SOCKET | 39 | #ifndef INVALID_SOCKET |
41 | #define INVALID_SOCKET -1 | 40 | #define INVALID_SOCKET -1 |
@@ -46,7 +45,6 @@ struct GNUNET_NETWORK_Handle | |||
46 | { | 45 | { |
47 | #ifndef MINGW | 46 | #ifndef MINGW |
48 | int fd; | 47 | int fd; |
49 | |||
50 | #else | 48 | #else |
51 | SOCKET fd; | 49 | SOCKET fd; |
52 | #endif | 50 | #endif |
@@ -337,19 +335,13 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc) | |||
337 | #ifdef MINGW | 335 | #ifdef MINGW |
338 | DWORD error = 0; | 336 | DWORD error = 0; |
339 | 337 | ||
340 | #if DEBUG_NETWORK | ||
341 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing 0x%x\n", | ||
342 | desc->fd); | ||
343 | #endif | ||
344 | SetLastError (0); | 338 | SetLastError (0); |
345 | ret = closesocket (desc->fd); | 339 | ret = closesocket (desc->fd); |
346 | error = WSAGetLastError (); | 340 | error = WSAGetLastError (); |
347 | SetErrnoFromWinsockError (error); | 341 | SetErrnoFromWinsockError (error); |
348 | #if DEBUG_NETWORK | ||
349 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 342 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
350 | "Closed 0x%x, closesocket() returned %d, GLE is %u\n", desc->fd, ret, | 343 | "Closed 0x%x, closesocket() returned %d, GLE is %u\n", desc->fd, ret, |
351 | error); | 344 | error); |
352 | #endif | ||
353 | #else | 345 | #else |
354 | ret = close (desc->fd); | 346 | ret = close (desc->fd); |
355 | #endif | 347 | #endif |
@@ -1301,40 +1293,32 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1301 | if (fh->type == GNUNET_PIPE) | 1293 | if (fh->type == GNUNET_PIPE) |
1302 | { | 1294 | { |
1303 | /* Read zero bytes to check the status of the pipe */ | 1295 | /* Read zero bytes to check the status of the pipe */ |
1304 | #if DEBUG_NETWORK | ||
1305 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Reading 0 bytes from the pipe 0x%x\n", | 1296 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Reading 0 bytes from the pipe 0x%x\n", |
1306 | fh->h); | 1297 | fh->h); |
1307 | #endif | ||
1308 | if (!ReadFile (fh->h, NULL, 0, NULL, fh->oOverlapRead)) | 1298 | if (!ReadFile (fh->h, NULL, 0, NULL, fh->oOverlapRead)) |
1309 | { | 1299 | { |
1310 | DWORD error_code = GetLastError (); | 1300 | DWORD error_code = GetLastError (); |
1311 | 1301 | ||
1312 | if (error_code == ERROR_IO_PENDING) | 1302 | if (error_code == ERROR_IO_PENDING) |
1313 | { | 1303 | { |
1314 | #if DEBUG_NETWORK | ||
1315 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1304 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1316 | "Adding the pipe's 0x%x overlapped event to the array as %d\n", | 1305 | "Adding the pipe's 0x%x overlapped event to the array as %d\n", |
1317 | fh->h, nhandles); | 1306 | fh->h, nhandles); |
1318 | #endif | ||
1319 | handle_array[nhandles++] = fh->oOverlapRead->hEvent; | 1307 | handle_array[nhandles++] = fh->oOverlapRead->hEvent; |
1320 | readArray[readPipes++] = fh; | 1308 | readArray[readPipes++] = fh; |
1321 | } | 1309 | } |
1322 | else | 1310 | else |
1323 | { | 1311 | { |
1324 | #if DEBUG_NETWORK | ||
1325 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1312 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1326 | "Read failed, adding the read ready event to the array as %d\n", nhandles); | 1313 | "Read failed, adding the read ready event to the array as %d\n", nhandles); |
1327 | #endif | ||
1328 | handle_array[nhandles++] = hEventReadReady; | 1314 | handle_array[nhandles++] = hEventReadReady; |
1329 | readArray[readPipes++] = fh; | 1315 | readArray[readPipes++] = fh; |
1330 | } | 1316 | } |
1331 | } | 1317 | } |
1332 | else | 1318 | else |
1333 | { | 1319 | { |
1334 | #if DEBUG_NETWORK | ||
1335 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1320 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1336 | "Adding the read ready event to the array as %d\n", nhandles); | 1321 | "Adding the read ready event to the array as %d\n", nhandles); |
1337 | #endif | ||
1338 | handle_array[nhandles++] = hEventReadReady; | 1322 | handle_array[nhandles++] = hEventReadReady; |
1339 | readArray[readPipes++] = fh; | 1323 | readArray[readPipes++] = fh; |
1340 | } | 1324 | } |
@@ -1349,10 +1333,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1349 | } | 1333 | } |
1350 | if (wfds && write_handles) | 1334 | if (wfds && write_handles) |
1351 | { | 1335 | { |
1352 | #if DEBUG_NETWORK | ||
1353 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1336 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1354 | "Adding the write ready event to the array as %d\n", nhandles); | 1337 | "Adding the write ready event to the array as %d\n", nhandles); |
1355 | #endif | ||
1356 | handle_array[nhandles++] = hEventPipeWrite; | 1338 | handle_array[nhandles++] = hEventPipeWrite; |
1357 | writePipePos = nhandles; | 1339 | writePipePos = nhandles; |
1358 | } | 1340 | } |
@@ -1386,10 +1368,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1386 | { | 1368 | { |
1387 | if (rfds) | 1369 | if (rfds) |
1388 | { | 1370 | { |
1389 | #if DEBUG_NETWORK | ||
1390 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1371 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1391 | "Adding the socket read event to the array as %d\n", nhandles); | 1372 | "Adding the socket read event to the array as %d\n", nhandles); |
1392 | #endif | ||
1393 | handle_array[nhandles++] = hEventRead; | 1373 | handle_array[nhandles++] = hEventRead; |
1394 | nSockEvents++; | 1374 | nSockEvents++; |
1395 | for (i = 0; i < rfds->sds.fd_count; i++) | 1375 | for (i = 0; i < rfds->sds.fd_count; i++) |
@@ -1403,10 +1383,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1403 | { | 1383 | { |
1404 | int wakeup = 0; | 1384 | int wakeup = 0; |
1405 | 1385 | ||
1406 | #if DEBUG_NETWORK | ||
1407 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1386 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1408 | "Adding the socket write event to the array as %d\n", nhandles); | 1387 | "Adding the socket write event to the array as %d\n", nhandles); |
1409 | #endif | ||
1410 | handle_array[nhandles++] = hEventWrite; | 1388 | handle_array[nhandles++] = hEventWrite; |
1411 | nSockEvents++; | 1389 | nSockEvents++; |
1412 | for (i = 0; i < wfds->sds.fd_count; i++) | 1390 | for (i = 0; i < wfds->sds.fd_count; i++) |
@@ -1416,10 +1394,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1416 | 1394 | ||
1417 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); | 1395 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); |
1418 | error = GetLastError (); | 1396 | error = GetLastError (); |
1419 | #if DEBUG_NETWORK | ||
1420 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1397 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1421 | "pre-send to the socket %d returned %d (%u)\n", i, status, error); | 1398 | "pre-send to the socket %d returned %d (%u)\n", i, status, error); |
1422 | #endif | ||
1423 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)) | 1399 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN)) |
1424 | wakeup = 1; | 1400 | wakeup = 1; |
1425 | WSAEventSelect (wfds->sds.fd_array[i], hEventWrite, | 1401 | WSAEventSelect (wfds->sds.fd_array[i], hEventWrite, |
@@ -1431,10 +1407,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1431 | } | 1407 | } |
1432 | if (efds) | 1408 | if (efds) |
1433 | { | 1409 | { |
1434 | #if DEBUG_NETWORK | ||
1435 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1410 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1436 | "Adding the socket error event to the array as %d\n", nhandles); | 1411 | "Adding the socket error event to the array as %d\n", nhandles); |
1437 | #endif | ||
1438 | handle_array[nhandles++] = hEventException; | 1412 | handle_array[nhandles++] = hEventException; |
1439 | nSockEvents++; | 1413 | nSockEvents++; |
1440 | for (i = 0; i < efds->sds.fd_count; i++) | 1414 | for (i = 0; i < efds->sds.fd_count; i++) |
@@ -1464,9 +1438,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1464 | #endif | 1438 | #endif |
1465 | 1439 | ||
1466 | returnedpos = returncode - WAIT_OBJECT_0; | 1440 | returnedpos = returncode - WAIT_OBJECT_0; |
1467 | #if DEBUG_NETWORK | ||
1468 | LOG (GNUNET_ERROR_TYPE_DEBUG, "return pos is : %d\n", returnedpos); | 1441 | LOG (GNUNET_ERROR_TYPE_DEBUG, "return pos is : %d\n", returnedpos); |
1469 | #endif | ||
1470 | 1442 | ||
1471 | /* FIXME: THIS LINE IS WRONG !! We should add to handles only handles that fired the events, not all ! */ | 1443 | /* FIXME: THIS LINE IS WRONG !! We should add to handles only handles that fired the events, not all ! */ |
1472 | /* | 1444 | /* |
@@ -1487,22 +1459,16 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1487 | retcode = select (nfds, &aread, &awrite, &aexcept, &tvslice); | 1459 | retcode = select (nfds, &aread, &awrite, &aexcept, &tvslice); |
1488 | if (retcode == -1) | 1460 | if (retcode == -1) |
1489 | retcode = 0; | 1461 | retcode = 0; |
1490 | #if DEBUG_NETWORK | ||
1491 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Select retcode : %d\n", retcode); | 1462 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Select retcode : %d\n", retcode); |
1492 | #endif | ||
1493 | } | 1463 | } |
1494 | /* FIXME: <= writePipePos? Really? */ | 1464 | /* FIXME: <= writePipePos? Really? */ |
1495 | if ((writePipePos != -1) && (returnedpos <= writePipePos)) | 1465 | if ((writePipePos != -1) && (returnedpos <= writePipePos)) |
1496 | { | 1466 | { |
1497 | GNUNET_CONTAINER_slist_append (handles_write, wfds->handles); | 1467 | GNUNET_CONTAINER_slist_append (handles_write, wfds->handles); |
1498 | retcode += write_handles; | 1468 | retcode += write_handles; |
1499 | #if DEBUG_NETWORK | ||
1500 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n"); | 1469 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Added write pipe\n"); |
1501 | #endif | ||
1502 | } | 1470 | } |
1503 | #if DEBUG_NETWORK | ||
1504 | LOG (GNUNET_ERROR_TYPE_DEBUG, "ReadPipes is : %d\n", readPipes); | 1471 | LOG (GNUNET_ERROR_TYPE_DEBUG, "ReadPipes is : %d\n", readPipes); |
1505 | #endif | ||
1506 | /* We have some pipes ready for read. */ | 1472 | /* We have some pipes ready for read. */ |
1507 | /* FIXME: it is supposed to work !! Only choose the Pipes who fired the event, but it is not working */ | 1473 | /* FIXME: it is supposed to work !! Only choose the Pipes who fired the event, but it is not working */ |
1508 | 1474 | ||
@@ -1532,11 +1498,9 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1532 | bret = | 1498 | bret = |
1533 | PeekNamedPipe (readArray[i]->h, NULL, 0, NULL, &waitstatus, NULL); | 1499 | PeekNamedPipe (readArray[i]->h, NULL, 0, NULL, &waitstatus, NULL); |
1534 | error = GetLastError (); | 1500 | error = GetLastError (); |
1535 | #if DEBUG_NETWORK | ||
1536 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1501 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1537 | "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n", | 1502 | "Peek at read pipe %d (0x%x) returned %d (%d bytes available) GLE %u\n", |
1538 | i, readArray[i]->h, bret, waitstatus, error); | 1503 | i, readArray[i]->h, bret, waitstatus, error); |
1539 | #endif | ||
1540 | if (bret == 0) | 1504 | if (bret == 0) |
1541 | { | 1505 | { |
1542 | if (error != ERROR_BROKEN_PIPE) | 1506 | if (error != ERROR_BROKEN_PIPE) |
@@ -1549,17 +1513,13 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1549 | readArray[i], | 1513 | readArray[i], |
1550 | sizeof (struct GNUNET_DISK_FileHandle)); | 1514 | sizeof (struct GNUNET_DISK_FileHandle)); |
1551 | retcode++; | 1515 | retcode++; |
1552 | #if DEBUG_NETWORK | ||
1553 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Added read Pipe 0x%x (0x%x)\n", | 1516 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Added read Pipe 0x%x (0x%x)\n", |
1554 | readArray[i], readArray[i]->h); | 1517 | readArray[i], readArray[i]->h); |
1555 | #endif | ||
1556 | } | 1518 | } |
1557 | } | 1519 | } |
1558 | waitstatus = WaitForSingleObject (hEventWrite, 0); | 1520 | waitstatus = WaitForSingleObject (hEventWrite, 0); |
1559 | #if DEBUG_NETWORK | ||
1560 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Wait for the write event returned %d\n", | 1521 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Wait for the write event returned %d\n", |
1561 | waitstatus); | 1522 | waitstatus); |
1562 | #endif | ||
1563 | if (waitstatus == WAIT_OBJECT_0) | 1523 | if (waitstatus == WAIT_OBJECT_0) |
1564 | { | 1524 | { |
1565 | for (i = 0; i < wfds->sds.fd_count; i++) | 1525 | for (i = 0; i < wfds->sds.fd_count; i++) |
@@ -1574,10 +1534,8 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1574 | 1534 | ||
1575 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); | 1535 | status = send (wfds->sds.fd_array[i], NULL, 0, 0); |
1576 | error = GetLastError (); | 1536 | error = GetLastError (); |
1577 | #if DEBUG_NETWORK | ||
1578 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1537 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1579 | "send to the socket %d returned %d (%u)\n", i, status, error); | 1538 | "send to the socket %d returned %d (%u)\n", i, status, error); |
1580 | #endif | ||
1581 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) || | 1539 | if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) || |
1582 | (status == -1 && gso_result == 0 && error == WSAENOTCONN && | 1540 | (status == -1 && gso_result == 0 && error == WSAENOTCONN && |
1583 | so_error == WSAECONNREFUSED)) | 1541 | so_error == WSAECONNREFUSED)) |
@@ -1614,9 +1572,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1614 | CancelIo (fh->h); | 1572 | CancelIo (fh->h); |
1615 | } | 1573 | } |
1616 | } | 1574 | } |
1617 | #if DEBUG_NETWORK | ||
1618 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing rfds\n"); | 1575 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing rfds\n"); |
1619 | #endif | ||
1620 | GNUNET_NETWORK_fdset_zero (rfds); | 1576 | GNUNET_NETWORK_fdset_zero (rfds); |
1621 | if (retcode != -1 && nhandles && (returnedpos < nhandles)) | 1577 | if (retcode != -1 && nhandles && (returnedpos < nhandles)) |
1622 | GNUNET_NETWORK_fdset_copy_native (rfds, &aread, retcode); | 1578 | GNUNET_NETWORK_fdset_copy_native (rfds, &aread, retcode); |
@@ -1629,9 +1585,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1629 | WSAEventSelect (wfds->sds.fd_array[i], hEventWrite, 0); | 1585 | WSAEventSelect (wfds->sds.fd_array[i], hEventWrite, 0); |
1630 | nsock++; | 1586 | nsock++; |
1631 | } | 1587 | } |
1632 | #if DEBUG_NETWORK | ||
1633 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing wfds\n"); | 1588 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing wfds\n"); |
1634 | #endif | ||
1635 | GNUNET_NETWORK_fdset_zero (wfds); | 1589 | GNUNET_NETWORK_fdset_zero (wfds); |
1636 | if (retcode != -1 && nhandles && (returnedpos < nhandles)) | 1590 | if (retcode != -1 && nhandles && (returnedpos < nhandles)) |
1637 | GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, retcode); | 1591 | GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, retcode); |
@@ -1644,9 +1598,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1644 | WSAEventSelect (efds->sds.fd_array[i], hEventException, 0); | 1598 | WSAEventSelect (efds->sds.fd_array[i], hEventException, 0); |
1645 | nsock++; | 1599 | nsock++; |
1646 | } | 1600 | } |
1647 | #if DEBUG_NETWORK | ||
1648 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing efds\n"); | 1601 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Zeroing efds\n"); |
1649 | #endif | ||
1650 | GNUNET_NETWORK_fdset_zero (efds); | 1602 | GNUNET_NETWORK_fdset_zero (efds); |
1651 | if (retcode != -1 && nhandles && (returnedpos < nhandles)) | 1603 | if (retcode != -1 && nhandles && (returnedpos < nhandles)) |
1652 | GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, retcode); | 1604 | GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, retcode); |