From 4967d5c949b9989e2ec440f93268f6fa774dd546 Mon Sep 17 00:00:00 2001 From: Nils Durner Date: Wed, 24 Nov 2010 19:41:11 +0000 Subject: [PATCH] fix MINGW --- src/util/network.c | 31 ++++++------------------------- src/util/scheduler.c | 34 ++++++++++++++++++++++++++++++++-- 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, const struct GNUNET_DISK_FileHandle *h) { #ifdef MINGW - HANDLE hw; - GNUNET_DISK_internal_file_handle_ (h, &hw, sizeof (HANDLE)); GNUNET_CONTAINER_slist_add (fds->handles, GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, - &hw, sizeof (HANDLE)); + h, sizeof (struct GNUNET_DISK_FileHandle)); #else int fd; @@ -852,23 +850,6 @@ GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, } -#if MINGW -/** - * Add a W32 file handle to the fd set - * @param fds fd set - * @param h the file handle to add - */ -void -GNUNET_NETWORK_fdset_handle_set_native_w32_handle (struct GNUNET_NETWORK_FDSet *fds, - HANDLE h) -{ - GNUNET_CONTAINER_slist_add (fds->handles, - GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, - &h, sizeof (HANDLE)); -} -#endif - - /** * Check if a file handle is part of an fd set * @param fds fd set @@ -881,8 +862,8 @@ GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds, { #ifdef MINGW - return GNUNET_CONTAINER_slist_contains (fds->handles, &h->h, - sizeof (HANDLE)); + return GNUNET_CONTAINER_slist_contains (fds->handles, h, + sizeof (struct GNUNET_DISK_FileHandle)); #else return FD_ISSET (h->fd, &fds->sds); #endif @@ -913,7 +894,7 @@ GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, } #else struct GNUNET_CONTAINER_SList_Iterator *it; - HANDLE *h; + struct GNUNET_DISK_FileHandle *h; int i; int j; @@ -931,9 +912,9 @@ GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, it = GNUNET_CONTAINER_slist_begin (fds1->handles); while (GNUNET_CONTAINER_slist_end (it) != GNUNET_YES) { - h = (HANDLE *) GNUNET_CONTAINER_slist_get (it, NULL); + h = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (it, NULL); if (GNUNET_CONTAINER_slist_contains - (fds2->handles, h, sizeof (HANDLE))) + (fds2->handles, h, sizeof (struct GNUNET_DISK_FileHandle))) { GNUNET_CONTAINER_slist_iter_destroy (it); 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, * @return unique task identifier for the job * only valid until "task" is started! */ +#ifndef MINGW GNUNET_SCHEDULER_TaskIdentifier add_without_sets (struct GNUNET_TIME_Relative delay, int rfd, @@ -1243,6 +1244,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay, #endif return t->id; } +#endif @@ -1267,11 +1269,25 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle * rfd, GNUNET_SCHEDULER_Task task, void *task_cls) { +#if MINGW + struct GNUNET_NETWORK_FDSet *rs; + GNUNET_SCHEDULER_TaskIdentifier ret; + + GNUNET_assert (rfd != NULL); + rs = GNUNET_NETWORK_fdset_create (); + GNUNET_NETWORK_fdset_set (rs, rfd); + ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), + GNUNET_SCHEDULER_NO_TASK, delay, + rs, NULL, task, task_cls); + GNUNET_NETWORK_fdset_destroy (rs); + return ret; +#else return add_without_sets (delay, GNUNET_NETWORK_get_fd (rfd), -1, task, task_cls); +#endif } @@ -1296,11 +1312,25 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle * wfd, GNUNET_SCHEDULER_Task task, void *task_cls) { +#if MINGW + struct GNUNET_NETWORK_FDSet *ws; + GNUNET_SCHEDULER_TaskIdentifier ret; + + GNUNET_assert (wfd != NULL); + ws = GNUNET_NETWORK_fdset_create (); + GNUNET_NETWORK_fdset_set (ws, wfd); + ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), + GNUNET_SCHEDULER_NO_TASK, delay, + NULL, ws, task, task_cls); + GNUNET_NETWORK_fdset_destroy (ws); + return ret; +#else return add_without_sets (delay, -1, GNUNET_NETWORK_get_fd (wfd), task, task_cls); +#endif } @@ -1332,7 +1362,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, GNUNET_assert (rfd != NULL); rs = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_handle_set (rs, rfd); - ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, + ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), GNUNET_SCHEDULER_NO_TASK, delay, rs, NULL, task, task_cls); GNUNET_NETWORK_fdset_destroy (rs); @@ -1379,7 +1409,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, GNUNET_assert (wfd != NULL); ws = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_handle_set (ws, wfd); - ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, + ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), GNUNET_SCHEDULER_NO_TASK, delay, NULL, ws, task, task_cls); GNUNET_NETWORK_fdset_destroy (ws); -- 2.25.1