[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25052 - gnunet/src/stream
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25052 - gnunet/src/stream |
Date: |
Mon, 19 Nov 2012 15:17:52 +0100 |
Author: harsha
Date: 2012-11-19 15:17:51 +0100 (Mon, 19 Nov 2012)
New Revision: 25052
Modified:
gnunet/src/stream/stream_api.c
gnunet/src/stream/test_stream_2peers.c
gnunet/src/stream/test_stream_local.c
Log:
- warn upon unclean socket close
Modified: gnunet/src/stream/stream_api.c
===================================================================
--- gnunet/src/stream/stream_api.c 2012-11-19 14:00:04 UTC (rev 25051)
+++ gnunet/src/stream/stream_api.c 2012-11-19 14:17:51 UTC (rev 25052)
@@ -3214,6 +3214,8 @@
GNUNET_STREAM_io_write_cancel (socket->write_handle);
//socket->write_handle = NULL;
}
+ GNUNET_break (GNUNET_YES == socket->receive_closed);
+ GNUNET_break (GNUNET_YES == socket->transmit_closed);
/* Terminate the ack'ing task if they are still present */
if (socket->ack_task_id != GNUNET_SCHEDULER_NO_TASK)
{
Modified: gnunet/src/stream/test_stream_2peers.c
===================================================================
--- gnunet/src/stream/test_stream_2peers.c 2012-11-19 14:00:04 UTC (rev
25051)
+++ gnunet/src/stream/test_stream_2peers.c 2012-11-19 14:17:51 UTC (rev
25052)
@@ -264,7 +264,6 @@
}
-
/**
* Shutdown sockets gracefully
*/
Modified: gnunet/src/stream/test_stream_local.c
===================================================================
--- gnunet/src/stream/test_stream_local.c 2012-11-19 14:00:04 UTC (rev
25051)
+++ gnunet/src/stream/test_stream_local.c 2012-11-19 14:17:51 UTC (rev
25052)
@@ -60,6 +60,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;
@@ -166,19 +171,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);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: shutdown\n");
- if (0 != abort_task)
- {
- GNUNET_SCHEDULER_cancel (abort_task);
- }
}
@@ -190,12 +192,40 @@
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n");
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
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25052 - gnunet/src/stream,
gnunet <=