diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-14 11:08:43 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-14 11:08:43 +0000 |
commit | 53da062e08f1d1d4392b3a40396bb45cc093e2ac (patch) | |
tree | 40b132f38c1d6b46476bfd9c1917070956ce4861 /src/include | |
parent | 1debac4608e78f4a7800252ba9a91b4f5a376b42 (diff) | |
download | gnunet-53da062e08f1d1d4392b3a40396bb45cc093e2ac.tar.gz gnunet-53da062e08f1d1d4392b3a40396bb45cc093e2ac.zip |
LRN: Added-the-ability-to-substitute-scheduler-select.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_disk_lib.h | 42 | ||||
-rw-r--r-- | src/include/gnunet_network_lib.h | 23 | ||||
-rw-r--r-- | src/include/gnunet_scheduler_lib.h | 31 | ||||
-rw-r--r-- | src/include/gnunet_transport_plugin.h | 3 |
4 files changed, 96 insertions, 3 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index 5403d256b..fdccebab0 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -36,6 +36,48 @@ struct GNUNET_DISK_FileHandle; | |||
36 | struct GNUNET_DISK_PipeHandle; | 36 | struct GNUNET_DISK_PipeHandle; |
37 | 37 | ||
38 | 38 | ||
39 | enum GNUNET_FILE_Type { | ||
40 | GNUNET_DISK_FILE, GNUNET_PIPE | ||
41 | }; | ||
42 | |||
43 | /** | ||
44 | * Handle used to access files (and pipes). | ||
45 | */ | ||
46 | struct GNUNET_DISK_FileHandle | ||
47 | { | ||
48 | |||
49 | #if WINDOWS | ||
50 | /** | ||
51 | * File handle under W32. | ||
52 | */ | ||
53 | HANDLE h; | ||
54 | |||
55 | /** | ||
56 | * Type | ||
57 | */ | ||
58 | enum GNUNET_FILE_Type type; | ||
59 | |||
60 | /** | ||
61 | * Structure for overlapped reading (for pipes) | ||
62 | */ | ||
63 | OVERLAPPED *oOverlapRead; | ||
64 | |||
65 | /** | ||
66 | * Structure for overlapped writing (for pipes) | ||
67 | */ | ||
68 | OVERLAPPED *oOverlapWrite; | ||
69 | #else | ||
70 | |||
71 | /** | ||
72 | * File handle on other OSes. | ||
73 | */ | ||
74 | int fd; | ||
75 | |||
76 | #endif /* | ||
77 | */ | ||
78 | }; | ||
79 | |||
80 | |||
39 | /* we need size_t, and since it can be both unsigned int | 81 | /* we need size_t, and since it can be both unsigned int |
40 | or unsigned long long, this IS platform dependent; | 82 | or unsigned long long, this IS platform dependent; |
41 | but "stdlib.h" should be portable 'enough' to be | 83 | but "stdlib.h" should be portable 'enough' to be |
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h index 1945d210f..aed4cabbf 100644 --- a/src/include/gnunet_network_lib.h +++ b/src/include/gnunet_network_lib.h | |||
@@ -45,7 +45,28 @@ struct GNUNET_NETWORK_Handle; | |||
45 | /** | 45 | /** |
46 | * @brief collection of IO descriptors | 46 | * @brief collection of IO descriptors |
47 | */ | 47 | */ |
48 | struct GNUNET_NETWORK_FDSet; | 48 | struct GNUNET_NETWORK_FDSet |
49 | { | ||
50 | |||
51 | /** | ||
52 | * Maximum number of any socket socket descriptor in the set (plus one) | ||
53 | */ | ||
54 | int nsds; | ||
55 | |||
56 | /** | ||
57 | * Bitset with the descriptors. | ||
58 | */ | ||
59 | fd_set sds; | ||
60 | |||
61 | #ifdef WINDOWS | ||
62 | /** | ||
63 | * Linked list of handles | ||
64 | */ | ||
65 | struct GNUNET_CONTAINER_SList *handles; | ||
66 | #endif | ||
67 | |||
68 | }; | ||
69 | |||
49 | 70 | ||
50 | 71 | ||
51 | #include "gnunet_disk_lib.h" | 72 | #include "gnunet_disk_lib.h" |
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index ce3261f0a..6b927bba8 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -195,6 +195,20 @@ typedef void (*GNUNET_SCHEDULER_Task) (void *cls, | |||
195 | 195 | ||
196 | 196 | ||
197 | /** | 197 | /** |
198 | * Signature of the select function used by the scheduler. | ||
199 | * GNUNET_NETWORK_socket_select matches it. | ||
200 | * | ||
201 | * @param rfds set of sockets to be checked for readability | ||
202 | * @param wfds set of sockets to be checked for writability | ||
203 | * @param efds set of sockets to be checked for exceptions | ||
204 | * @param timeout relative value when to return | ||
205 | * @return number of selected sockets, GNUNET_SYSERR on error | ||
206 | */ | ||
207 | typedef int (*GNUNET_SCHEDULER_select) (struct GNUNET_NETWORK_FDSet *rfds, | ||
208 | struct GNUNET_NETWORK_FDSet *wfds, | ||
209 | struct GNUNET_NETWORK_FDSet *efds, | ||
210 | struct GNUNET_TIME_Relative timeout); | ||
211 | /** | ||
198 | * Initialize and run scheduler. This function will return when all | 212 | * Initialize and run scheduler. This function will return when all |
199 | * tasks have completed. On systems with signals, receiving a SIGTERM | 213 | * tasks have completed. On systems with signals, receiving a SIGTERM |
200 | * (and other similar signals) will cause "GNUNET_SCHEDULER_shutdown" | 214 | * (and other similar signals) will cause "GNUNET_SCHEDULER_shutdown" |
@@ -494,6 +508,23 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
494 | GNUNET_SCHEDULER_Task task, | 508 | GNUNET_SCHEDULER_Task task, |
495 | void *task_cls); | 509 | void *task_cls); |
496 | 510 | ||
511 | /** | ||
512 | * Sets the select function to use in the scheduler (scheduler_select). | ||
513 | * | ||
514 | * @param new_select new select function to use | ||
515 | * @return previously used select function | ||
516 | */ | ||
517 | GNUNET_SCHEDULER_select | ||
518 | GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select); | ||
519 | |||
520 | /** | ||
521 | * Gets the select function currently used in the scheduler. | ||
522 | * | ||
523 | * @return currently used select function | ||
524 | */ | ||
525 | GNUNET_SCHEDULER_select | ||
526 | GNUNET_SCHEDULER_get_select (); | ||
527 | |||
497 | #if 0 /* keep Emacsens' auto-indent happy */ | 528 | #if 0 /* keep Emacsens' auto-indent happy */ |
498 | { | 529 | { |
499 | #endif | 530 | #endif |
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h index b47843188..37eef9427 100644 --- a/src/include/gnunet_transport_plugin.h +++ b/src/include/gnunet_transport_plugin.h | |||
@@ -92,8 +92,7 @@ typedef void (*GNUNET_TRANSPORT_SessionEnd) (void *cls, | |||
92 | * @param cls closure | 92 | * @param cls closure |
93 | * @param peer (claimed) identity of the other peer | 93 | * @param peer (claimed) identity of the other peer |
94 | * @param message the message, NULL if we only care about | 94 | * @param message the message, NULL if we only care about |
95 | * learning about the delay until we should receive again -- FIXME! | 95 | * learning about the delay until we should receive again |
96 | * @param distance in overlay hops; use 1 unless DV (or 0 if message == NULL) | ||
97 | * @param session identifier used for this session (NULL for plugins | 96 | * @param session identifier used for this session (NULL for plugins |
98 | * that do not offer bi-directional communication to the sender | 97 | * that do not offer bi-directional communication to the sender |
99 | * using the same "connection") | 98 | * using the same "connection") |