diff options
author | Nils Durner <durner@gnunet.org> | 2009-08-23 22:11:49 +0000 |
---|---|---|
committer | Nils Durner <durner@gnunet.org> | 2009-08-23 22:11:49 +0000 |
commit | 2518cfc0a86865ebe4d0550e0013ed52a494231b (patch) | |
tree | e9a130b782597e18bcff24a9fdab6e5c6aae1f9c /src/util/test_scheduler.c | |
parent | 2ae973618f3b51fa9bbf5532eaa1352cafc24ecc (diff) | |
download | gnunet-2518cfc0a86865ebe4d0550e0013ed52a494231b.tar.gz gnunet-2518cfc0a86865ebe4d0550e0013ed52a494231b.zip |
low level network API
Diffstat (limited to 'src/util/test_scheduler.c')
-rw-r--r-- | src/util/test_scheduler.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index d5a93ed7d..34def7b1e 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_scheduler_lib.h" | 26 | #include "gnunet_scheduler_lib.h" |
27 | #include "gnunet_time_lib.h" | 27 | #include "gnunet_time_lib.h" |
28 | #include "gnunet_disk_lib.h" | ||
28 | 29 | ||
29 | #define VERBOSE GNUNET_NO | 30 | #define VERBOSE GNUNET_NO |
30 | 31 | ||
@@ -55,7 +56,8 @@ task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
55 | (*ok) = 5; | 56 | (*ok) = 5; |
56 | } | 57 | } |
57 | 58 | ||
58 | static int fds[2]; | 59 | struct GNUNET_DISK_PipeHandle *p; |
60 | static struct GNUNET_DISK_FileHandle *fds[2]; | ||
59 | 61 | ||
60 | 62 | ||
61 | static void | 63 | static void |
@@ -64,10 +66,9 @@ taskWrt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
64 | static char c; | 66 | static char c; |
65 | int *ok = cls; | 67 | int *ok = cls; |
66 | GNUNET_assert (6 == *ok); | 68 | GNUNET_assert (6 == *ok); |
67 | GNUNET_assert (FD_ISSET (fds[1], tc->write_ready)); | 69 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->write_ready, fds[1])); |
68 | (*ok) = 7; | 70 | (*ok) = 7; |
69 | GNUNET_assert (1 == WRITE (fds[1], &c, 1)); | 71 | GNUNET_assert (1 == GNUNET_DISK_file_write (fds[1], &c, 1)); |
70 | GNUNET_break (0 == CLOSE (fds[1])); | ||
71 | } | 72 | } |
72 | 73 | ||
73 | 74 | ||
@@ -92,9 +93,8 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
92 | static char c; | 93 | static char c; |
93 | int *ok = cls; | 94 | int *ok = cls; |
94 | GNUNET_assert (7 == *ok); | 95 | GNUNET_assert (7 == *ok); |
95 | GNUNET_assert (FD_ISSET (fds[0], tc->read_ready)); | 96 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); |
96 | GNUNET_assert (1 == READ (fds[0], &c, 1)); | 97 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); |
97 | GNUNET_break (0 == CLOSE (fds[0])); | ||
98 | (*ok) = 8; | 98 | (*ok) = 8; |
99 | GNUNET_SCHEDULER_add_after (tc->sched, | 99 | GNUNET_SCHEDULER_add_after (tc->sched, |
100 | GNUNET_NO, | 100 | GNUNET_NO, |
@@ -114,14 +114,17 @@ task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
114 | int *ok = cls; | 114 | int *ok = cls; |
115 | GNUNET_assert (5 == *ok); | 115 | GNUNET_assert (5 == *ok); |
116 | (*ok) = 6; | 116 | (*ok) = 6; |
117 | GNUNET_assert (0 == PIPE (fds)); | 117 | p = GNUNET_DISK_pipe (GNUNET_NO); |
118 | GNUNET_SCHEDULER_add_read (tc->sched, | 118 | GNUNET_assert (NULL != p); |
119 | fds[0] = GNUNET_DISK_pipe_handle (p, 0); | ||
120 | fds[1] = GNUNET_DISK_pipe_handle (p, 1); | ||
121 | GNUNET_SCHEDULER_add_read_file (tc->sched, | ||
119 | GNUNET_NO, | 122 | GNUNET_NO, |
120 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 123 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
121 | GNUNET_SCHEDULER_NO_TASK, | 124 | GNUNET_SCHEDULER_NO_TASK, |
122 | GNUNET_TIME_UNIT_FOREVER_REL, | 125 | GNUNET_TIME_UNIT_FOREVER_REL, |
123 | fds[0], &taskRd, cls); | 126 | fds[0], &taskRd, cls); |
124 | GNUNET_SCHEDULER_add_write (tc->sched, | 127 | GNUNET_SCHEDULER_add_write_file (tc->sched, |
125 | GNUNET_NO, | 128 | GNUNET_NO, |
126 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 129 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
127 | GNUNET_SCHEDULER_NO_TASK, | 130 | GNUNET_SCHEDULER_NO_TASK, |
@@ -256,6 +259,7 @@ main (int argc, char *argv[]) | |||
256 | ret += check (); | 259 | ret += check (); |
257 | ret += checkSignal (); | 260 | ret += checkSignal (); |
258 | ret += checkCancel (); | 261 | ret += checkCancel (); |
262 | GNUNET_DISK_pipe_close (p); | ||
259 | 263 | ||
260 | return ret; | 264 | return ret; |
261 | } | 265 | } |