[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25054 - gnunet/src/stream
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25054 - gnunet/src/stream |
Date: |
Mon, 19 Nov 2012 16:02:23 +0100 |
Author: harsha
Date: 2012-11-19 16:02:23 +0100 (Mon, 19 Nov 2012)
New Revision: 25054
Modified:
gnunet/src/stream/perf_stream_api.c
gnunet/src/stream/test_stream_big.c
gnunet/src/stream/test_stream_sequence_wraparound.c
Log:
- fixes
Modified: gnunet/src/stream/perf_stream_api.c
===================================================================
--- gnunet/src/stream/perf_stream_api.c 2012-11-19 14:22:16 UTC (rev 25053)
+++ gnunet/src/stream/perf_stream_api.c 2012-11-19 15:02:23 UTC (rev 25054)
@@ -126,6 +126,11 @@
struct GNUNET_PeerIdentity id;
/**
+ * Peer's shutdown handle
+ */
+ struct GNUNET_STREAM_ShutdownHandle *shutdown_handle;
+
+ /**
* Bytes the peer has written
*/
size_t bytes_wrote;
@@ -372,7 +377,7 @@
* Shutdown nicely
*/
static void
-do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
switch (test_step)
{
@@ -419,9 +424,36 @@
if (GNUNET_SCHEDULER_NO_TASK != read_task)
GNUNET_SCHEDULER_cancel (read_task);
result = GNUNET_SYSERR;
- do_shutdown (cls, tc);
+ do_close (cls, tc);
}
+
+/**
+ * Completion callback for shutdown
+ *
+ * @param cls the closure from GNUNET_STREAM_shutdown call
+ * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
+ * SHUT_RDWR)
+ */
+static void
+shutdown_completion (void *cls,
+ int operation)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STREAM shutdown successful\n");
+ GNUNET_SCHEDULER_add_now (&do_close, cls);
+}
+
+
+/**
+ * Shutdown sockets gracefully
+ */
+static void
+do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ peer_data[0].shutdown_handle = GNUNET_STREAM_shutdown (peer_data[0].socket,
SHUT_RDWR,
+ &shutdown_completion,
cls);
+}
+
/**
* Scheduler call back; to be executed when a new stream is connected
Property changes on: gnunet/src/stream/perf_stream_api.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +1,2 ##
+/branches/gnunet/mantis_0001616/src/stream/perf_stream_api.c:13878-14093
+/gnunet/src/stream/test_stream_local.c:25052
\ No newline at end of property
Modified: gnunet/src/stream/test_stream_big.c
===================================================================
--- gnunet/src/stream/test_stream_big.c 2012-11-19 14:22:16 UTC (rev 25053)
+++ gnunet/src/stream/test_stream_big.c 2012-11-19 15:02:23 UTC (rev 25054)
@@ -61,6 +61,11 @@
struct GNUNET_STREAM_IOReadHandle *io_read_handle;
/**
+ * Peer's shutdown handle
+ */
+ struct GNUNET_STREAM_ShutdownHandle *shutdown_handle;
+
+ /**
* Bytes the peer has written
*/
unsigned int bytes_wrote;
@@ -88,19 +93,16 @@
* Shutdown nicely
*/
static void
-do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ if (GNUNET_SCHEDULER_NO_TASK != abort_task)
+ GNUNET_SCHEDULER_cancel (abort_task);
if (NULL != peer1.socket)
GNUNET_STREAM_close (peer1.socket);
if (NULL != peer2.socket)
GNUNET_STREAM_close (peer2.socket);
if (NULL != peer2_listen_socket)
GNUNET_STREAM_listen_close (peer2_listen_socket); /* Close listen socket */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: shutdown\n");
- if (GNUNET_SCHEDULER_NO_TASK != abort_task)
- GNUNET_SCHEDULER_cancel (abort_task);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Wait\n");
- GNUNET_SCHEDULER_shutdown ();
}
@@ -115,11 +117,39 @@
GNUNET_SCHEDULER_cancel (read_task);
result = GNUNET_SYSERR;
abort_task = GNUNET_SCHEDULER_NO_TASK;
- do_shutdown (cls, tc);
+ do_close (cls, tc);
}
/**
+ * Completion callback for shutdown
+ *
+ * @param cls the closure from GNUNET_STREAM_shutdown call
+ * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
+ * SHUT_RDWR)
+ */
+static void
+shutdown_completion (void *cls,
+ int operation)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STREAM shutdown successful\n");
+ GNUNET_SCHEDULER_add_now (&do_close, cls);
+}
+
+
+/**
+ * Shutdown sockets gracefully
+ */
+static void
+do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ result = GNUNET_OK;
+ peer1.shutdown_handle = GNUNET_STREAM_shutdown (peer1.socket, SHUT_RDWR,
+ &shutdown_completion, cls);
+}
+
+
+/**
* The write completion function; called upon writing some data to stream or
* upon error
*
Property changes on: gnunet/src/stream/test_stream_big.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +1,2 ##
+/branches/gnunet/mantis_0001616/src/stream/test_stream_big.c:13878-14093
+/gnunet/src/stream/test_stream_local.c:25052
\ No newline at end of property
Modified: gnunet/src/stream/test_stream_sequence_wraparound.c
===================================================================
--- gnunet/src/stream/test_stream_sequence_wraparound.c 2012-11-19 14:22:16 UTC
(rev 25053)
+++ gnunet/src/stream/test_stream_sequence_wraparound.c 2012-11-19 15:02:23 UTC
(rev 25054)
@@ -64,6 +64,11 @@
struct GNUNET_STREAM_IOReadHandle *io_read_handle;
/**
+ * Peer's shutdown handle
+ */
+ struct GNUNET_STREAM_ShutdownHandle *shutdown_handle;
+
+ /**
* Bytes the peer has written
*/
unsigned int bytes_wrote;
@@ -93,19 +98,16 @@
* Shutdown nicely
*/
static void
-do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ if (GNUNET_SCHEDULER_NO_TASK != abort_task)
+ GNUNET_SCHEDULER_cancel (abort_task);
if (NULL != peer1.socket)
GNUNET_STREAM_close (peer1.socket);
if (NULL != peer2.socket)
GNUNET_STREAM_close (peer2.socket);
if (NULL != peer2_listen_socket)
GNUNET_STREAM_listen_close (peer2_listen_socket); /* Close listen socket */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: shutdown\n");
- if (0 != abort_task)
- {
- GNUNET_SCHEDULER_cancel (abort_task);
- }
}
@@ -121,12 +123,40 @@
GNUNET_SCHEDULER_cancel (read_task);
}
result = GNUNET_SYSERR;
- abort_task = 0;
- do_shutdown (cls, tc);
+ abort_task = GNUNET_SCHEDULER_NO_TASK;
+ do_close (cls, tc);
}
/**
+ * Completion callback for shutdown
+ *
+ * @param cls the closure from GNUNET_STREAM_shutdown call
+ * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
+ * SHUT_RDWR)
+ */
+static void
+shutdown_completion (void *cls,
+ int operation)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STREAM shutdown successful\n");
+ GNUNET_SCHEDULER_add_now (&do_close, cls);
+}
+
+
+/**
+ * Shutdown sockets gracefully
+ */
+static void
+do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ result = GNUNET_OK;
+ peer1.shutdown_handle = GNUNET_STREAM_shutdown (peer1.socket, SHUT_RDWR,
+ &shutdown_completion, cls);
+}
+
+
+/**
* The write completion function; called upon writing some data to stream or
* upon error
*
Property changes on: gnunet/src/stream/test_stream_sequence_wraparound.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +1,2 ##
+/branches/gnunet/mantis_0001616/src/stream/test_stream_sequence_wraparound.c:13878-14093
+/gnunet/src/stream/test_stream_local.c:25052
\ No newline at end of property
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25054 - gnunet/src/stream,
gnunet <=