diff options
-rw-r--r-- | src/include/gnunet_stream_lib.h | 21 | ||||
-rw-r--r-- | src/stream/stream_api.c | 33 |
2 files changed, 51 insertions, 3 deletions
diff --git a/src/include/gnunet_stream_lib.h b/src/include/gnunet_stream_lib.h index 5a2f9b2e4..a16d052d6 100644 --- a/src/include/gnunet_stream_lib.h +++ b/src/include/gnunet_stream_lib.h | |||
@@ -125,18 +125,35 @@ GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
125 | 125 | ||
126 | 126 | ||
127 | /** | 127 | /** |
128 | * Handle for shutdown | ||
129 | */ | ||
130 | struct GNUNET_STREAM_ShutdownHandle; | ||
131 | |||
132 | |||
133 | /** | ||
128 | * Shutdown the stream for reading or writing (man 2 shutdown). | 134 | * Shutdown the stream for reading or writing (man 2 shutdown). |
129 | * | 135 | * |
130 | * @param socket the stream socket | 136 | * @param socket the stream socket |
131 | * @param how SHUT_RD, SHUT_WR or SHUT_RDWR | 137 | * @param how SHUT_RD, SHUT_WR or SHUT_RDWR |
138 | * @return the shutdown handle | ||
132 | */ | 139 | */ |
133 | void | 140 | struct GNUNET_STREAM_ShutdownHandle * |
134 | GNUNET_STREAM_shutdown (struct GNUNET_STREAM_Socket *socket, | 141 | GNUNET_STREAM_shutdown (struct GNUNET_STREAM_Socket *socket, |
135 | int how); | 142 | int how); |
136 | 143 | ||
137 | 144 | ||
138 | /** | 145 | /** |
139 | * Closes the stream | 146 | * Cancels a pending shutdown |
147 | * | ||
148 | * @param the shutdown handle returned from GNUNET_STREAM_shutdown | ||
149 | */ | ||
150 | void | ||
151 | GNUNET_STREAM_shutdown_cancel (struct GNUNET_STREAM_ShutdownHandle *handle); | ||
152 | |||
153 | |||
154 | /** | ||
155 | * Closes the stream and frees the associated state. The stream should be | ||
156 | * shutdown before closing. | ||
140 | * | 157 | * |
141 | * @param socket the stream socket | 158 | * @param socket the stream socket |
142 | */ | 159 | */ |
diff --git a/src/stream/stream_api.c b/src/stream/stream_api.c index 0749d8c5f..2180f919a 100644 --- a/src/stream/stream_api.c +++ b/src/stream/stream_api.c | |||
@@ -428,10 +428,28 @@ struct GNUNET_STREAM_IOReadHandle | |||
428 | 428 | ||
429 | 429 | ||
430 | /** | 430 | /** |
431 | * Handle for Shutdown | ||
432 | */ | ||
433 | struct GNUNET_STREAM_ShutdownHandle | ||
434 | { | ||
435 | /** | ||
436 | * The socket associated with this shutdown handle | ||
437 | */ | ||
438 | struct GNUNET_STREAM_Socket *socket; | ||
439 | |||
440 | /** | ||
441 | * Which operation to shutdown? SHUT_RD, SHUT_WR or SHUT_RDWR | ||
442 | */ | ||
443 | int operation; | ||
444 | }; | ||
445 | |||
446 | |||
447 | /** | ||
431 | * Default value in seconds for various timeouts | 448 | * Default value in seconds for various timeouts |
432 | */ | 449 | */ |
433 | static unsigned int default_timeout = 10; | 450 | static unsigned int default_timeout = 10; |
434 | 451 | ||
452 | |||
435 | /** | 453 | /** |
436 | * Callback function for sending queued message | 454 | * Callback function for sending queued message |
437 | * | 455 | * |
@@ -2356,11 +2374,24 @@ GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2356 | * | 2374 | * |
2357 | * @param socket the stream socket | 2375 | * @param socket the stream socket |
2358 | * @param how SHUT_RD, SHUT_WR or SHUT_RDWR | 2376 | * @param how SHUT_RD, SHUT_WR or SHUT_RDWR |
2377 | * @return the shutdown handle | ||
2359 | */ | 2378 | */ |
2360 | void | 2379 | struct GNUNET_STREAM_ShutdownHandle * |
2361 | GNUNET_STREAM_shutdown (struct GNUNET_STREAM_Socket *socket, | 2380 | GNUNET_STREAM_shutdown (struct GNUNET_STREAM_Socket *socket, |
2362 | int how) | 2381 | int how) |
2363 | { | 2382 | { |
2383 | return NULL; | ||
2384 | } | ||
2385 | |||
2386 | |||
2387 | /** | ||
2388 | * Cancels a pending shutdown | ||
2389 | * | ||
2390 | * @param the shutdown handle returned from GNUNET_STREAM_shutdown | ||
2391 | */ | ||
2392 | void | ||
2393 | GNUNET_STREAM_shutdown_cancel (struct GNUNET_STREAM_ShutdownHandle *handle) | ||
2394 | { | ||
2364 | return; | 2395 | return; |
2365 | } | 2396 | } |
2366 | 2397 | ||