diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-06 08:58:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-06 08:58:04 +0000 |
commit | 2c1e75c6dddcba773349971229f2e8fdbfd72f59 (patch) | |
tree | 6a6a13c124e9db2d4df58b209afc373414973a0a /src/util | |
parent | 29a8deb6ba442fe476accc22d1ca6fca654fe3f8 (diff) | |
download | gnunet-2c1e75c6dddcba773349971229f2e8fdbfd72f59.tar.gz gnunet-2c1e75c6dddcba773349971229f2e8fdbfd72f59.zip |
vminko: new API to delete a TransmitContext (slightly modified patch from #1822)
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/server_tc.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/util/server_tc.c b/src/util/server_tc.c index 127131032..5e9a9e946 100644 --- a/src/util/server_tc.c +++ b/src/util/server_tc.c | |||
@@ -82,10 +82,7 @@ transmit_response (void *cls, size_t size, void *buf) | |||
82 | 82 | ||
83 | if (buf == NULL) | 83 | if (buf == NULL) |
84 | { | 84 | { |
85 | GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR); | 85 | GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR); |
86 | GNUNET_SERVER_client_drop (tc->client); | ||
87 | GNUNET_free_non_null (tc->buf); | ||
88 | GNUNET_free (tc); | ||
89 | return 0; | 86 | return 0; |
90 | } | 87 | } |
91 | if (tc->total - tc->off > size) | 88 | if (tc->total - tc->off > size) |
@@ -96,6 +93,7 @@ transmit_response (void *cls, size_t size, void *buf) | |||
96 | tc->off += msize; | 93 | tc->off += msize; |
97 | if (tc->total == tc->off) | 94 | if (tc->total == tc->off) |
98 | { | 95 | { |
96 | |||
99 | GNUNET_SERVER_receive_done (tc->client, GNUNET_OK); | 97 | GNUNET_SERVER_receive_done (tc->client, GNUNET_OK); |
100 | GNUNET_SERVER_client_drop (tc->client); | 98 | GNUNET_SERVER_client_drop (tc->client); |
101 | GNUNET_free_non_null (tc->buf); | 99 | GNUNET_free_non_null (tc->buf); |
@@ -112,10 +110,7 @@ transmit_response (void *cls, size_t size, void *buf) | |||
112 | tc)) | 110 | tc)) |
113 | { | 111 | { |
114 | GNUNET_break (0); | 112 | GNUNET_break (0); |
115 | GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR); | 113 | GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR); |
116 | GNUNET_SERVER_client_drop (tc->client); | ||
117 | GNUNET_free_non_null (tc->buf); | ||
118 | GNUNET_free (tc); | ||
119 | } | 114 | } |
120 | } | 115 | } |
121 | return msize; | 116 | return msize; |
@@ -219,11 +214,33 @@ GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc, | |||
219 | &transmit_response, tc)) | 214 | &transmit_response, tc)) |
220 | { | 215 | { |
221 | GNUNET_break (0); | 216 | GNUNET_break (0); |
222 | GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR); | 217 | GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR); |
223 | GNUNET_SERVER_client_drop (tc->client); | ||
224 | GNUNET_free_non_null (tc->buf); | ||
225 | GNUNET_free (tc); | ||
226 | } | 218 | } |
227 | } | 219 | } |
228 | 220 | ||
221 | |||
222 | /** | ||
223 | * Destroy a transmission context. This function must not be called | ||
224 | * after 'GNUNET_SERVER_transmit_context_run'. | ||
225 | * | ||
226 | * @param tc transmission context to destroy | ||
227 | * @param success code to give to 'GNUNET_SERVER_receive_done' for | ||
228 | * the client: GNUNET_OK to keep the connection open and | ||
229 | * continue to receive | ||
230 | * GNUNET_NO to close the connection (normal behavior) | ||
231 | * GNUNET_SYSERR to close the connection (signal | ||
232 | * serious error) | ||
233 | */ | ||
234 | void | ||
235 | GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContext | ||
236 | *tc, | ||
237 | int success) | ||
238 | { | ||
239 | GNUNET_SERVER_receive_done (tc->client, success); | ||
240 | GNUNET_SERVER_client_drop (tc->client); | ||
241 | GNUNET_free_non_null (tc->buf); | ||
242 | GNUNET_free (tc); | ||
243 | } | ||
244 | |||
245 | |||
229 | /* end of server_tc.c */ | 246 | /* end of server_tc.c */ |