aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Durner <durner@gnunet.org>2010-11-24 19:41:11 +0000
committerNils Durner <durner@gnunet.org>2010-11-24 19:41:11 +0000
commit4967d5c949b9989e2ec440f93268f6fa774dd546 (patch)
treeace8079c6efd4c008fc8279e69fb03d8440fce45
parent635353dfc45ff76838db307c1df9faf56b3e188f (diff)
downloadgnunet-4967d5c949b9989e2ec440f93268f6fa774dd546.tar.gz
gnunet-4967d5c949b9989e2ec440f93268f6fa774dd546.zip
fix MINGW
-rw-r--r--src/util/network.c31
-rw-r--r--src/util/scheduler.c34
2 files changed, 38 insertions, 27 deletions
diff --git a/src/util/network.c b/src/util/network.c
index 452f28706..3b76a35d1 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -835,11 +835,9 @@ GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
835 const struct GNUNET_DISK_FileHandle *h) 835 const struct GNUNET_DISK_FileHandle *h)
836{ 836{
837#ifdef MINGW 837#ifdef MINGW
838 HANDLE hw;
839 GNUNET_DISK_internal_file_handle_ (h, &hw, sizeof (HANDLE));
840 GNUNET_CONTAINER_slist_add (fds->handles, 838 GNUNET_CONTAINER_slist_add (fds->handles,
841 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, 839 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
842 &hw, sizeof (HANDLE)); 840 h, sizeof (struct GNUNET_DISK_FileHandle));
843 841
844#else 842#else
845 int fd; 843 int fd;
@@ -852,23 +850,6 @@ GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
852} 850}
853 851
854 852
855#if MINGW
856/**
857 * Add a W32 file handle to the fd set
858 * @param fds fd set
859 * @param h the file handle to add
860 */
861void
862GNUNET_NETWORK_fdset_handle_set_native_w32_handle (struct GNUNET_NETWORK_FDSet *fds,
863 HANDLE h)
864{
865 GNUNET_CONTAINER_slist_add (fds->handles,
866 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
867 &h, sizeof (HANDLE));
868}
869#endif
870
871
872/** 853/**
873 * Check if a file handle is part of an fd set 854 * Check if a file handle is part of an fd set
874 * @param fds fd set 855 * @param fds fd set
@@ -881,8 +862,8 @@ GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds,
881{ 862{
882 863
883#ifdef MINGW 864#ifdef MINGW
884 return GNUNET_CONTAINER_slist_contains (fds->handles, &h->h, 865 return GNUNET_CONTAINER_slist_contains (fds->handles, h,
885 sizeof (HANDLE)); 866 sizeof (struct GNUNET_DISK_FileHandle));
886#else 867#else
887 return FD_ISSET (h->fd, &fds->sds); 868 return FD_ISSET (h->fd, &fds->sds);
888#endif 869#endif
@@ -913,7 +894,7 @@ GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1,
913 } 894 }
914#else 895#else
915 struct GNUNET_CONTAINER_SList_Iterator *it; 896 struct GNUNET_CONTAINER_SList_Iterator *it;
916 HANDLE *h; 897 struct GNUNET_DISK_FileHandle *h;
917 int i; 898 int i;
918 int j; 899 int j;
919 900
@@ -931,9 +912,9 @@ GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1,
931 it = GNUNET_CONTAINER_slist_begin (fds1->handles); 912 it = GNUNET_CONTAINER_slist_begin (fds1->handles);
932 while (GNUNET_CONTAINER_slist_end (it) != GNUNET_YES) 913 while (GNUNET_CONTAINER_slist_end (it) != GNUNET_YES)
933 { 914 {
934 h = (HANDLE *) GNUNET_CONTAINER_slist_get (it, NULL); 915 h = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (it, NULL);
935 if (GNUNET_CONTAINER_slist_contains 916 if (GNUNET_CONTAINER_slist_contains
936 (fds2->handles, h, sizeof (HANDLE))) 917 (fds2->handles, h, sizeof (struct GNUNET_DISK_FileHandle)))
937 { 918 {
938 GNUNET_CONTAINER_slist_iter_destroy (it); 919 GNUNET_CONTAINER_slist_iter_destroy (it);
939 return GNUNET_YES; 920 return GNUNET_YES;
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 49d491bd7..13b3f8552 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -1194,6 +1194,7 @@ GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task,
1194 * @return unique task identifier for the job 1194 * @return unique task identifier for the job
1195 * only valid until "task" is started! 1195 * only valid until "task" is started!
1196 */ 1196 */
1197#ifndef MINGW
1197GNUNET_SCHEDULER_TaskIdentifier 1198GNUNET_SCHEDULER_TaskIdentifier
1198add_without_sets (struct GNUNET_TIME_Relative delay, 1199add_without_sets (struct GNUNET_TIME_Relative delay,
1199 int rfd, 1200 int rfd,
@@ -1243,6 +1244,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay,
1243#endif 1244#endif
1244 return t->id; 1245 return t->id;
1245} 1246}
1247#endif
1246 1248
1247 1249
1248 1250
@@ -1267,11 +1269,25 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay,
1267 struct GNUNET_NETWORK_Handle * rfd, 1269 struct GNUNET_NETWORK_Handle * rfd,
1268 GNUNET_SCHEDULER_Task task, void *task_cls) 1270 GNUNET_SCHEDULER_Task task, void *task_cls)
1269{ 1271{
1272#if MINGW
1273 struct GNUNET_NETWORK_FDSet *rs;
1274 GNUNET_SCHEDULER_TaskIdentifier ret;
1275
1276 GNUNET_assert (rfd != NULL);
1277 rs = GNUNET_NETWORK_fdset_create ();
1278 GNUNET_NETWORK_fdset_set (rs, rfd);
1279 ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority),
1280 GNUNET_SCHEDULER_NO_TASK, delay,
1281 rs, NULL, task, task_cls);
1282 GNUNET_NETWORK_fdset_destroy (rs);
1283 return ret;
1284#else
1270 return add_without_sets (delay, 1285 return add_without_sets (delay,
1271 GNUNET_NETWORK_get_fd (rfd), 1286 GNUNET_NETWORK_get_fd (rfd),
1272 -1, 1287 -1,
1273 task, 1288 task,
1274 task_cls); 1289 task_cls);
1290#endif
1275} 1291}
1276 1292
1277 1293
@@ -1296,11 +1312,25 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay,
1296 struct GNUNET_NETWORK_Handle * wfd, 1312 struct GNUNET_NETWORK_Handle * wfd,
1297 GNUNET_SCHEDULER_Task task, void *task_cls) 1313 GNUNET_SCHEDULER_Task task, void *task_cls)
1298{ 1314{
1315#if MINGW
1316 struct GNUNET_NETWORK_FDSet *ws;
1317 GNUNET_SCHEDULER_TaskIdentifier ret;
1318
1319 GNUNET_assert (wfd != NULL);
1320 ws = GNUNET_NETWORK_fdset_create ();
1321 GNUNET_NETWORK_fdset_set (ws, wfd);
1322 ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority),
1323 GNUNET_SCHEDULER_NO_TASK, delay,
1324 NULL, ws, task, task_cls);
1325 GNUNET_NETWORK_fdset_destroy (ws);
1326 return ret;
1327#else
1299 return add_without_sets (delay, 1328 return add_without_sets (delay,
1300 -1, 1329 -1,
1301 GNUNET_NETWORK_get_fd (wfd), 1330 GNUNET_NETWORK_get_fd (wfd),
1302 task, 1331 task,
1303 task_cls); 1332 task_cls);
1333#endif
1304} 1334}
1305 1335
1306 1336
@@ -1332,7 +1362,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay,
1332 GNUNET_assert (rfd != NULL); 1362 GNUNET_assert (rfd != NULL);
1333 rs = GNUNET_NETWORK_fdset_create (); 1363 rs = GNUNET_NETWORK_fdset_create ();
1334 GNUNET_NETWORK_fdset_handle_set (rs, rfd); 1364 GNUNET_NETWORK_fdset_handle_set (rs, rfd);
1335 ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, 1365 ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority),
1336 GNUNET_SCHEDULER_NO_TASK, delay, 1366 GNUNET_SCHEDULER_NO_TASK, delay,
1337 rs, NULL, task, task_cls); 1367 rs, NULL, task, task_cls);
1338 GNUNET_NETWORK_fdset_destroy (rs); 1368 GNUNET_NETWORK_fdset_destroy (rs);
@@ -1379,7 +1409,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay,
1379 GNUNET_assert (wfd != NULL); 1409 GNUNET_assert (wfd != NULL);
1380 ws = GNUNET_NETWORK_fdset_create (); 1410 ws = GNUNET_NETWORK_fdset_create ();
1381 GNUNET_NETWORK_fdset_handle_set (ws, wfd); 1411 GNUNET_NETWORK_fdset_handle_set (ws, wfd);
1382 ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, 1412 ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority),
1383 GNUNET_SCHEDULER_NO_TASK, 1413 GNUNET_SCHEDULER_NO_TASK,
1384 delay, NULL, ws, task, task_cls); 1414 delay, NULL, ws, task, task_cls);
1385 GNUNET_NETWORK_fdset_destroy (ws); 1415 GNUNET_NETWORK_fdset_destroy (ws);