aboutsummaryrefslogtreecommitdiff
path: root/src/stream
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-11-19 15:02:23 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-11-19 15:02:23 +0000
commite70d7f62e59d59846cfb744a4c15cd772ec357be (patch)
tree88ac8027bbc9f5af6ce5cbee8270717cd83cf52f /src/stream
parentdade0aea8ecf688a19f410a0bc66aaa84acb1dd0 (diff)
downloadgnunet-e70d7f62e59d59846cfb744a4c15cd772ec357be.tar.gz
gnunet-e70d7f62e59d59846cfb744a4c15cd772ec357be.zip
- fixes
Diffstat (limited to 'src/stream')
-rw-r--r--src/stream/perf_stream_api.c36
-rw-r--r--src/stream/test_stream_big.c44
-rw-r--r--src/stream/test_stream_sequence_wraparound.c46
3 files changed, 109 insertions, 17 deletions
diff --git a/src/stream/perf_stream_api.c b/src/stream/perf_stream_api.c
index 3c1d56f84..cd68310bc 100644
--- a/src/stream/perf_stream_api.c
+++ b/src/stream/perf_stream_api.c
@@ -126,6 +126,11 @@ struct PeerData
126 struct GNUNET_PeerIdentity id; 126 struct GNUNET_PeerIdentity id;
127 127
128 /** 128 /**
129 * Peer's shutdown handle
130 */
131 struct GNUNET_STREAM_ShutdownHandle *shutdown_handle;
132
133 /**
129 * Bytes the peer has written 134 * Bytes the peer has written
130 */ 135 */
131 size_t bytes_wrote; 136 size_t bytes_wrote;
@@ -372,7 +377,7 @@ free_meter (struct ProgressMeter *meter)
372 * Shutdown nicely 377 * Shutdown nicely
373 */ 378 */
374static void 379static void
375do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 380do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
376{ 381{
377 switch (test_step) 382 switch (test_step)
378 { 383 {
@@ -419,7 +424,34 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
419 if (GNUNET_SCHEDULER_NO_TASK != read_task) 424 if (GNUNET_SCHEDULER_NO_TASK != read_task)
420 GNUNET_SCHEDULER_cancel (read_task); 425 GNUNET_SCHEDULER_cancel (read_task);
421 result = GNUNET_SYSERR; 426 result = GNUNET_SYSERR;
422 do_shutdown (cls, tc); 427 do_close (cls, tc);
428}
429
430
431/**
432 * Completion callback for shutdown
433 *
434 * @param cls the closure from GNUNET_STREAM_shutdown call
435 * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
436 * SHUT_RDWR)
437 */
438static void
439shutdown_completion (void *cls,
440 int operation)
441{
442 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STREAM shutdown successful\n");
443 GNUNET_SCHEDULER_add_now (&do_close, cls);
444}
445
446
447/**
448 * Shutdown sockets gracefully
449 */
450static void
451do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
452{
453 peer_data[0].shutdown_handle = GNUNET_STREAM_shutdown (peer_data[0].socket, SHUT_RDWR,
454 &shutdown_completion, cls);
423} 455}
424 456
425 457
diff --git a/src/stream/test_stream_big.c b/src/stream/test_stream_big.c
index 05da82691..d5875dd55 100644
--- a/src/stream/test_stream_big.c
+++ b/src/stream/test_stream_big.c
@@ -61,6 +61,11 @@ struct PeerData
61 struct GNUNET_STREAM_IOReadHandle *io_read_handle; 61 struct GNUNET_STREAM_IOReadHandle *io_read_handle;
62 62
63 /** 63 /**
64 * Peer's shutdown handle
65 */
66 struct GNUNET_STREAM_ShutdownHandle *shutdown_handle;
67
68 /**
64 * Bytes the peer has written 69 * Bytes the peer has written
65 */ 70 */
66 unsigned int bytes_wrote; 71 unsigned int bytes_wrote;
@@ -88,19 +93,16 @@ static int result;
88 * Shutdown nicely 93 * Shutdown nicely
89 */ 94 */
90static void 95static void
91do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 96do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
92{ 97{
98 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
99 GNUNET_SCHEDULER_cancel (abort_task);
93 if (NULL != peer1.socket) 100 if (NULL != peer1.socket)
94 GNUNET_STREAM_close (peer1.socket); 101 GNUNET_STREAM_close (peer1.socket);
95 if (NULL != peer2.socket) 102 if (NULL != peer2.socket)
96 GNUNET_STREAM_close (peer2.socket); 103 GNUNET_STREAM_close (peer2.socket);
97 if (NULL != peer2_listen_socket) 104 if (NULL != peer2_listen_socket)
98 GNUNET_STREAM_listen_close (peer2_listen_socket); /* Close listen socket */ 105 GNUNET_STREAM_listen_close (peer2_listen_socket); /* Close listen socket */
99 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: shutdown\n");
100 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
101 GNUNET_SCHEDULER_cancel (abort_task);
102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Wait\n");
103 GNUNET_SCHEDULER_shutdown ();
104} 106}
105 107
106 108
@@ -115,7 +117,35 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
115 GNUNET_SCHEDULER_cancel (read_task); 117 GNUNET_SCHEDULER_cancel (read_task);
116 result = GNUNET_SYSERR; 118 result = GNUNET_SYSERR;
117 abort_task = GNUNET_SCHEDULER_NO_TASK; 119 abort_task = GNUNET_SCHEDULER_NO_TASK;
118 do_shutdown (cls, tc); 120 do_close (cls, tc);
121}
122
123
124/**
125 * Completion callback for shutdown
126 *
127 * @param cls the closure from GNUNET_STREAM_shutdown call
128 * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
129 * SHUT_RDWR)
130 */
131static void
132shutdown_completion (void *cls,
133 int operation)
134{
135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STREAM shutdown successful\n");
136 GNUNET_SCHEDULER_add_now (&do_close, cls);
137}
138
139
140/**
141 * Shutdown sockets gracefully
142 */
143static void
144do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
145{
146 result = GNUNET_OK;
147 peer1.shutdown_handle = GNUNET_STREAM_shutdown (peer1.socket, SHUT_RDWR,
148 &shutdown_completion, cls);
119} 149}
120 150
121 151
diff --git a/src/stream/test_stream_sequence_wraparound.c b/src/stream/test_stream_sequence_wraparound.c
index f23171661..61e28cf72 100644
--- a/src/stream/test_stream_sequence_wraparound.c
+++ b/src/stream/test_stream_sequence_wraparound.c
@@ -64,6 +64,11 @@ struct PeerData
64 struct GNUNET_STREAM_IOReadHandle *io_read_handle; 64 struct GNUNET_STREAM_IOReadHandle *io_read_handle;
65 65
66 /** 66 /**
67 * Peer's shutdown handle
68 */
69 struct GNUNET_STREAM_ShutdownHandle *shutdown_handle;
70
71 /**
67 * Bytes the peer has written 72 * Bytes the peer has written
68 */ 73 */
69 unsigned int bytes_wrote; 74 unsigned int bytes_wrote;
@@ -93,19 +98,16 @@ static int result;
93 * Shutdown nicely 98 * Shutdown nicely
94 */ 99 */
95static void 100static void
96do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 101do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
97{ 102{
103 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
104 GNUNET_SCHEDULER_cancel (abort_task);
98 if (NULL != peer1.socket) 105 if (NULL != peer1.socket)
99 GNUNET_STREAM_close (peer1.socket); 106 GNUNET_STREAM_close (peer1.socket);
100 if (NULL != peer2.socket) 107 if (NULL != peer2.socket)
101 GNUNET_STREAM_close (peer2.socket); 108 GNUNET_STREAM_close (peer2.socket);
102 if (NULL != peer2_listen_socket) 109 if (NULL != peer2_listen_socket)
103 GNUNET_STREAM_listen_close (peer2_listen_socket); /* Close listen socket */ 110 GNUNET_STREAM_listen_close (peer2_listen_socket); /* Close listen socket */
104 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: shutdown\n");
105 if (0 != abort_task)
106 {
107 GNUNET_SCHEDULER_cancel (abort_task);
108 }
109} 111}
110 112
111 113
@@ -121,8 +123,36 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
121 GNUNET_SCHEDULER_cancel (read_task); 123 GNUNET_SCHEDULER_cancel (read_task);
122 } 124 }
123 result = GNUNET_SYSERR; 125 result = GNUNET_SYSERR;
124 abort_task = 0; 126 abort_task = GNUNET_SCHEDULER_NO_TASK;
125 do_shutdown (cls, tc); 127 do_close (cls, tc);
128}
129
130
131/**
132 * Completion callback for shutdown
133 *
134 * @param cls the closure from GNUNET_STREAM_shutdown call
135 * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
136 * SHUT_RDWR)
137 */
138static void
139shutdown_completion (void *cls,
140 int operation)
141{
142 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STREAM shutdown successful\n");
143 GNUNET_SCHEDULER_add_now (&do_close, cls);
144}
145
146
147/**
148 * Shutdown sockets gracefully
149 */
150static void
151do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
152{
153 result = GNUNET_OK;
154 peer1.shutdown_handle = GNUNET_STREAM_shutdown (peer1.socket, SHUT_RDWR,
155 &shutdown_completion, cls);
126} 156}
127 157
128 158