aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-10-29 20:18:06 +0000
committerChristian Grothoff <christian@grothoff.org>2010-10-29 20:18:06 +0000
commitbcb3c77b61fb9bff6d3c73414f8586c1e7163a3a (patch)
tree3937e038156d0db2b99b8035e786f8ac0df8cf97
parente427e88c6ae96e9b7eb30ebdf4c6b238226ad3e7 (diff)
downloadgnunet-bcb3c77b61fb9bff6d3c73414f8586c1e7163a3a.tar.gz
gnunet-bcb3c77b61fb9bff6d3c73414f8586c1e7163a3a.zip
w32 patch from LRN
-rw-r--r--src/util/network.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/util/network.c b/src/util/network.c
index 941fb836b..58d67ed19 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -899,6 +899,7 @@ int
899GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, 899GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1,
900 const struct GNUNET_NETWORK_FDSet *fds2) 900 const struct GNUNET_NETWORK_FDSet *fds2)
901{ 901{
902#ifndef MINGW
902 int nfds; 903 int nfds;
903 904
904 nfds = fds1->nsds; 905 nfds = fds1->nsds;
@@ -910,26 +911,36 @@ GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1,
910 if (FD_ISSET (nfds, &fds1->sds) && FD_ISSET (nfds, &fds2->sds)) 911 if (FD_ISSET (nfds, &fds1->sds) && FD_ISSET (nfds, &fds2->sds))
911 return GNUNET_YES; 912 return GNUNET_YES;
912 } 913 }
913#ifdef MINGW 914#else
914 { 915 struct GNUNET_CONTAINER_SList_Iterator *it;
915 struct GNUNET_CONTAINER_SList_Iterator *it; 916 HANDLE *h;
917 int i;
918 int j;
916 919
917 for (it = GNUNET_CONTAINER_slist_begin (fds1->handles); 920 /*This code is somewhat hacky, we are not supposed to know what's
918 GNUNET_CONTAINER_slist_end (it) != GNUNET_YES; 921 inside of fd_set; also the O(n^2) is really bad... */
919 GNUNET_CONTAINER_slist_next (it)) 922
920 { 923 for (i = 0; i < fds1->sds.fd_count; i++)
921 HANDLE *h; 924 {
922 925 for (j = 0; j < fds2->sds.fd_count; j++)
923 h = (HANDLE *) GNUNET_CONTAINER_slist_get ((const struct GNUNET_CONTAINER_SList_Iterator *)it, NULL); 926 {
924 if (GNUNET_CONTAINER_slist_contains 927 if (fds1->sds.fd_array[i] == fds2->sds.fd_array[j])
925 (fds2->handles, h, sizeof (HANDLE))) 928 return GNUNET_YES;
926 { 929 }
927 GNUNET_CONTAINER_slist_iter_destroy (it);
928 return GNUNET_YES;
929 }
930 }
931 GNUNET_CONTAINER_slist_iter_destroy (it);
932 } 930 }
931 it = GNUNET_CONTAINER_slist_begin (fds1->handles);
932 while (GNUNET_CONTAINER_slist_end (it) != GNUNET_YES)
933 {
934 h = (HANDLE *) GNUNET_CONTAINER_slist_get (it, NULL);
935 if (GNUNET_CONTAINER_slist_contains
936 (fds2->handles, h, sizeof (HANDLE)))
937 {
938 GNUNET_CONTAINER_slist_iter_destroy (it);
939 return GNUNET_YES;
940 }
941 GNUNET_CONTAINER_slist_next (it);
942 }
943 GNUNET_CONTAINER_slist_iter_destroy (it);
933#endif 944#endif
934 return GNUNET_NO; 945 return GNUNET_NO;
935} 946}