gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20067 - gnunet/src/stream


From: gnunet
Subject: [GNUnet-SVN] r20067 - gnunet/src/stream
Date: Mon, 27 Feb 2012 13:51:42 +0100

Author: harsha
Date: 2012-02-27 13:51:42 +0100 (Mon, 27 Feb 2012)
New Revision: 20067

Modified:
   gnunet/src/stream/stream_api.c
Log:
-added read io timeout

Modified: gnunet/src/stream/stream_api.c
===================================================================
--- gnunet/src/stream/stream_api.c      2012-02-27 12:34:57 UTC (rev 20066)
+++ gnunet/src/stream/stream_api.c      2012-02-27 12:51:42 UTC (rev 20067)
@@ -237,6 +237,11 @@
   void *copy_buffer;
 
   /**
+   * Task identifier for the read io timeout task
+   */
+  GNUNET_SCHEDULER_TaskIdentifier read_io_timeout_task;
+
+  /**
    * The state of the protocol associated with this socket
    */
   enum State state;
@@ -687,6 +692,9 @@
   valid_read_size = socket->copy_buffer_size - socket->copy_buffer_read_offset;
   GNUNET_assert (0 != valid_read_size);
 
+  /* Cancel the read_io_timeout_task */
+  GNUNET_SCHEDULER_cancel (socket->read_io_timeout_task);
+  /* Call the data processor */
   read_size = socket->read_handle->proc (socket->read_handle->proc_cls,
                                          socket->status,
                                          socket->copy_buffer 
@@ -785,7 +793,27 @@
 }
 
 
+
 /**
+ * Cancels the existing read io handle
+ *
+ * @param cls the closure from the SCHEDULER call
+ * @param tc the task context
+ */
+static void
+cancel_read_io (void *cls, 
+                const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_STREAM_Socket *socket = cls;
+
+  GNUNET_assert (NULL != socket->read_handle);
+  
+  GNUNET_free (socket->read_handle);
+  socket->read_handle = NULL;
+}
+
+
+/**
  * Handler for DATA messages; Same for both client and server
  *
  * @param socket the socket through which the ack was received
@@ -2153,5 +2181,9 @@
   else
     prepare_buffer_for_read (socket);
 
+  socket->read_io_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
+                                                               &cancel_read_io,
+                                                               socket);
+
   return read_handle;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]