diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-06-26 17:15:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-06-26 17:15:48 +0000 |
commit | 37194f115116b2ea38d5ccb3c7fd8d3a75d77641 (patch) | |
tree | 30a4349a6e0c7b0649213fce1fbf4dd8368dec42 /src/util/network.c | |
parent | 1174c809820401ec254a701b4d478a8e88b8af59 (diff) | |
download | gnunet-37194f115116b2ea38d5ccb3c7fd8d3a75d77641.tar.gz gnunet-37194f115116b2ea38d5ccb3c7fd8d3a75d77641.zip |
scheduler optimizing
Diffstat (limited to 'src/util/network.c')
-rw-r--r-- | src/util/network.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/util/network.c b/src/util/network.c index 69b36bc51..37e40aa1a 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -800,6 +800,23 @@ void GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, | |||
800 | 800 | ||
801 | 801 | ||
802 | /** | 802 | /** |
803 | * Test native fd in a set | ||
804 | * | ||
805 | * @param to set to test, NULL for empty set | ||
806 | * @param nfd native FD to test, or -1 for none | ||
807 | * @return GNUNET_YES if FD is set in the set | ||
808 | */ | ||
809 | int | ||
810 | GNUNET_NETWORK_fdset_test_native (const struct GNUNET_NETWORK_FDSet *to, | ||
811 | int nfd) | ||
812 | { | ||
813 | if ( (nfd == -1) || (to == NULL) ) | ||
814 | return GNUNET_NO; | ||
815 | return FD_ISSET (nfd, &to->sds) ? GNUNET_YES : GNUNET_NO; | ||
816 | } | ||
817 | |||
818 | |||
819 | /** | ||
803 | * Add a file handle to the fd set | 820 | * Add a file handle to the fd set |
804 | * @param fds fd set | 821 | * @param fds fd set |
805 | * @param h the file handle to add | 822 | * @param h the file handle to add |
@@ -1174,19 +1191,15 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1174 | while (retcode == 0 && (ms_total == INFINITE || GetTickCount () < limit)); | 1191 | while (retcode == 0 && (ms_total == INFINITE || GetTickCount () < limit)); |
1175 | 1192 | ||
1176 | if (retcode != -1) | 1193 | if (retcode != -1) |
1177 | |||
1178 | { | 1194 | { |
1179 | if (rfds) | 1195 | if (rfds) |
1180 | |||
1181 | { | 1196 | { |
1182 | GNUNET_NETWORK_fdset_zero (rfds); | 1197 | GNUNET_NETWORK_fdset_zero (rfds); |
1183 | GNUNET_NETWORK_fdset_copy_native (rfds, &aread, retcode); | 1198 | GNUNET_NETWORK_fdset_copy_native (rfds, &aread, retcode); |
1184 | GNUNET_CONTAINER_slist_clear (rfds->handles); | 1199 | GNUNET_CONTAINER_slist_clear (rfds->handles); |
1185 | GNUNET_CONTAINER_slist_append (rfds->handles, handles_read); | 1200 | GNUNET_CONTAINER_slist_append (rfds->handles, handles_read); |
1186 | |||
1187 | } | 1201 | } |
1188 | if (wfds) | 1202 | if (wfds) |
1189 | |||
1190 | { | 1203 | { |
1191 | GNUNET_NETWORK_fdset_zero (wfds); | 1204 | GNUNET_NETWORK_fdset_zero (wfds); |
1192 | GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, retcode); | 1205 | GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, retcode); |
@@ -1194,7 +1207,6 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1194 | GNUNET_CONTAINER_slist_append (wfds->handles, handles_write); | 1207 | GNUNET_CONTAINER_slist_append (wfds->handles, handles_write); |
1195 | } | 1208 | } |
1196 | if (efds) | 1209 | if (efds) |
1197 | |||
1198 | { | 1210 | { |
1199 | GNUNET_NETWORK_fdset_zero (efds); | 1211 | GNUNET_NETWORK_fdset_zero (efds); |
1200 | GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, retcode); | 1212 | GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, retcode); |