diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-11 21:21:56 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-11 21:21:56 +0000 |
commit | 3d7fefedc9ba60bd8e8448efe8b628446d958536 (patch) | |
tree | 61ce41a52cd6e7232cead77818ef265993b2427e /src/util/network.c | |
parent | 4a0398474db197abed243a123fb971fbeeffab4b (diff) | |
download | gnunet-3d7fefedc9ba60bd8e8448efe8b628446d958536.tar.gz gnunet-3d7fefedc9ba60bd8e8448efe8b628446d958536.zip |
changing time measurement from milliseconds to microseconds
Diffstat (limited to 'src/util/network.c')
-rw-r--r-- | src/util/network.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/util/network.c b/src/util/network.c index 7a51a8b67..8398b9fab 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009, 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2009-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
7 | by the Free Software Foundation; either version 2, or (at your | 7 | by the Free Software Foundation; either version 3, or (at your |
8 | option) any later version. | 8 | option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
@@ -1332,7 +1332,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | if ((nfds == 0) && | 1334 | if ((nfds == 0) && |
1335 | (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) | 1335 | (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) |
1336 | #ifdef MINGW | 1336 | #ifdef MINGW |
1337 | && handles == 0 | 1337 | && handles == 0 |
1338 | #endif | 1338 | #endif |
@@ -1345,25 +1345,26 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1345 | "select"); | 1345 | "select"); |
1346 | } | 1346 | } |
1347 | #ifndef MINGW | 1347 | #ifndef MINGW |
1348 | tv.tv_sec = timeout.rel_value / GNUNET_TIME_UNIT_SECONDS.rel_value; | 1348 | tv.tv_sec = timeout.rel_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us; |
1349 | tv.tv_usec = | 1349 | tv.tv_usec = |
1350 | 1000 * (timeout.rel_value - | 1350 | (timeout.rel_value_us - |
1351 | (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value)); | 1351 | (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us)); |
1352 | return select (nfds, (rfds != NULL) ? &rfds->sds : NULL, | 1352 | return select (nfds, |
1353 | (wfds != NULL) ? &wfds->sds : NULL, | 1353 | (NULL != rfds) ? &rfds->sds : NULL, |
1354 | (efds != NULL) ? &efds->sds : NULL, | 1354 | (NULL != wfds) ? &wfds->sds : NULL, |
1355 | (timeout.rel_value == | 1355 | (NULL != efds) ? &efds->sds : NULL, |
1356 | GNUNET_TIME_UNIT_FOREVER_REL.rel_value) ? NULL : &tv); | 1356 | (timeout.rel_value_us == |
1357 | GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) ? NULL : &tv); | ||
1357 | 1358 | ||
1358 | #else | 1359 | #else |
1359 | #define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set)) | 1360 | #define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set)) |
1360 | /* calculate how long we need to wait in milliseconds */ | 1361 | /* calculate how long we need to wait in milliseconds */ |
1361 | if (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) | 1362 | if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) |
1362 | ms_total = INFINITE; | 1363 | ms_total = INFINITE; |
1363 | else | 1364 | else |
1364 | { | 1365 | { |
1365 | ms_total = timeout.rel_value / GNUNET_TIME_UNIT_MILLISECONDS.rel_value; | 1366 | ms_total = timeout.rel_value_us / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us; |
1366 | if (timeout.rel_value / GNUNET_TIME_UNIT_MILLISECONDS.rel_value > 0xFFFFFFFFLL - 1) | 1367 | if (timeout.rel_value_us / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us > 0xFFFFFFFFLL - 1) |
1367 | { | 1368 | { |
1368 | GNUNET_break (0); | 1369 | GNUNET_break (0); |
1369 | ms_total = 0xFFFFFFFF - 1; | 1370 | ms_total = 0xFFFFFFFF - 1; |
@@ -1376,7 +1377,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1376 | return 0; | 1377 | return 0; |
1377 | } | 1378 | } |
1378 | 1379 | ||
1379 | if (select_thread == NULL) | 1380 | if (NULL == select_thread) |
1380 | { | 1381 | { |
1381 | SOCKET select_listening_socket = -1; | 1382 | SOCKET select_listening_socket = -1; |
1382 | struct sockaddr_in s_in; | 1383 | struct sockaddr_in s_in; |
@@ -1742,15 +1743,16 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1742 | if (nfds > 0) | 1743 | if (nfds > 0) |
1743 | { | 1744 | { |
1744 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1745 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1745 | "Adding the socket event to the array as %d\n", nhandles); | 1746 | "Adding the socket event to the array as %d\n", |
1747 | nhandles); | ||
1746 | handle_array[nhandles++] = select_finished_event; | 1748 | handle_array[nhandles++] = select_finished_event; |
1747 | if (timeout.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) | 1749 | if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) |
1748 | sp.tv = NULL; | 1750 | sp.tv = NULL; |
1749 | else | 1751 | else |
1750 | { | 1752 | { |
1751 | select_timeout.tv_sec = timeout.rel_value / GNUNET_TIME_UNIT_SECONDS.rel_value; | 1753 | select_timeout.tv_sec = timeout.rel_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us; |
1752 | select_timeout.tv_usec = 1000 * (timeout.rel_value - | 1754 | select_timeout.tv_usec =(timeout.rel_value_us - |
1753 | (select_timeout.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value)); | 1755 | (select_timeout.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us)); |
1754 | sp.tv = &select_timeout; | 1756 | sp.tv = &select_timeout; |
1755 | } | 1757 | } |
1756 | FD_SET (select_wakeup_socket, &aread); | 1758 | FD_SET (select_wakeup_socket, &aread); |