-added shutdown handle and cancel
authorSree Harsha Totakura <totakura@in.tum.de>
Fri, 6 Apr 2012 07:36:40 +0000 (07:36 +0000)
committerSree Harsha Totakura <totakura@in.tum.de>
Fri, 6 Apr 2012 07:36:40 +0000 (07:36 +0000)
src/include/gnunet_stream_lib.h
src/stream/stream_api.c

index 5a2f9b2e49cc0702ab92cd5483a3f1bbebbdbbd2..a16d052d65f5576e2d8ab887483af524274aaf65 100644 (file)
@@ -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
  */
index 0749d8c5f3e2a3a94160e0eb778d849b3d150d16..2180f919ac1b9e34c8af2642494d517f0c4b599c 100644 (file)
@@ -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;
 }