From: Sree Harsha Totakura Date: Fri, 6 Apr 2012 07:36:40 +0000 (+0000) Subject: -added shutdown handle and cancel X-Git-Tag: initial-import-from-subversion-38251~13979 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=67480d02e8729308defdc5256dd00dc3b887a5ea;p=oweals%2Fgnunet.git -added shutdown handle and cancel --- 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 @@ -124,19 +124,36 @@ GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg, ...); +/** + * Handle for shutdown + */ +struct GNUNET_STREAM_ShutdownHandle; + + /** * Shutdown the stream for reading or writing (man 2 shutdown). * * @param socket the stream socket * @param how SHUT_RD, SHUT_WR or SHUT_RDWR + * @return the shutdown handle */ -void +struct GNUNET_STREAM_ShutdownHandle * GNUNET_STREAM_shutdown (struct GNUNET_STREAM_Socket *socket, int how); /** - * Closes the stream + * Cancels a pending shutdown + * + * @param the shutdown handle returned from GNUNET_STREAM_shutdown + */ +void +GNUNET_STREAM_shutdown_cancel (struct GNUNET_STREAM_ShutdownHandle *handle); + + +/** + * Closes the stream and frees the associated state. The stream should be + * shutdown before closing. * * @param socket the stream socket */ 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 @@ -427,11 +427,29 @@ struct GNUNET_STREAM_IOReadHandle }; +/** + * Handle for Shutdown + */ +struct GNUNET_STREAM_ShutdownHandle +{ + /** + * The socket associated with this shutdown handle + */ + struct GNUNET_STREAM_Socket *socket; + + /** + * Which operation to shutdown? SHUT_RD, SHUT_WR or SHUT_RDWR + */ + int operation; +}; + + /** * Default value in seconds for various timeouts */ static unsigned int default_timeout = 10; + /** * Callback function for sending queued message * @@ -2356,10 +2374,23 @@ GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg, * * @param socket the stream socket * @param how SHUT_RD, SHUT_WR or SHUT_RDWR + * @return the shutdown handle */ -void +struct GNUNET_STREAM_ShutdownHandle * GNUNET_STREAM_shutdown (struct GNUNET_STREAM_Socket *socket, int how) +{ + return NULL; +} + + +/** + * Cancels a pending shutdown + * + * @param the shutdown handle returned from GNUNET_STREAM_shutdown + */ +void +GNUNET_STREAM_shutdown_cancel (struct GNUNET_STREAM_ShutdownHandle *handle) { return; }