aboutsummaryrefslogtreecommitdiff
path: root/src/util/server_tc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/server_tc.c')
-rw-r--r--src/util/server_tc.c76
1 files changed, 37 insertions, 39 deletions
diff --git a/src/util/server_tc.c b/src/util/server_tc.c
index 020fd86db..ce40db19c 100644
--- a/src/util/server_tc.c
+++ b/src/util/server_tc.c
@@ -83,10 +83,10 @@ transmit_response (void *cls, size_t size, void *buf)
83 size_t msize; 83 size_t msize;
84 84
85 if (buf == NULL) 85 if (buf == NULL)
86 { 86 {
87 GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR); 87 GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR);
88 return 0; 88 return 0;
89 } 89 }
90 if (tc->total - tc->off > size) 90 if (tc->total - tc->off > size)
91 msize = size; 91 msize = size;
92 else 92 else
@@ -94,28 +94,27 @@ transmit_response (void *cls, size_t size, void *buf)
94 memcpy (buf, &tc->buf[tc->off], msize); 94 memcpy (buf, &tc->buf[tc->off], msize);
95 tc->off += msize; 95 tc->off += msize;
96 if (tc->total == tc->off) 96 if (tc->total == tc->off)
97 { 97 {
98 98
99 GNUNET_SERVER_receive_done (tc->client, GNUNET_OK); 99 GNUNET_SERVER_receive_done (tc->client, GNUNET_OK);
100 GNUNET_SERVER_client_drop (tc->client); 100 GNUNET_SERVER_client_drop (tc->client);
101 GNUNET_free_non_null (tc->buf); 101 GNUNET_free_non_null (tc->buf);
102 GNUNET_free (tc); 102 GNUNET_free (tc);
103 } 103 }
104 else 104 else
105 {
106 if (NULL ==
107 GNUNET_SERVER_notify_transmit_ready (tc->client,
108 GNUNET_MIN (MIN_BLOCK_SIZE,
109 tc->total - tc->off),
110 GNUNET_TIME_absolute_get_remaining
111 (tc->timeout), &transmit_response,
112 tc))
105 { 113 {
106 if (NULL == 114 GNUNET_break (0);
107 GNUNET_SERVER_notify_transmit_ready (tc->client, 115 GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR);
108 GNUNET_MIN (MIN_BLOCK_SIZE,
109 tc->total -
110 tc->off),
111 GNUNET_TIME_absolute_get_remaining
112 (tc->timeout),
113 &transmit_response, tc))
114 {
115 GNUNET_break (0);
116 GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR);
117 }
118 } 116 }
117 }
119 return msize; 118 return msize;
120} 119}
121 120
@@ -151,10 +150,9 @@ GNUNET_SERVER_transmit_context_create (struct GNUNET_SERVER_Client *client)
151 * @param type type of the message 150 * @param type type of the message
152 */ 151 */
153void 152void
154GNUNET_SERVER_transmit_context_append_data (struct 153GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitContext
155 GNUNET_SERVER_TransmitContext *tc, 154 *tc, const void *data,
156 const void *data, size_t length, 155 size_t length, uint16_t type)
157 uint16_t type)
158{ 156{
159 struct GNUNET_MessageHeader *msg; 157 struct GNUNET_MessageHeader *msg;
160 size_t size; 158 size_t size;
@@ -181,10 +179,10 @@ GNUNET_SERVER_transmit_context_append_data (struct
181 */ 179 */
182void 180void
183GNUNET_SERVER_transmit_context_append_message (struct 181GNUNET_SERVER_transmit_context_append_message (struct
184 GNUNET_SERVER_TransmitContext 182 GNUNET_SERVER_TransmitContext
185 *tc, 183 *tc,
186 const struct 184 const struct GNUNET_MessageHeader
187 GNUNET_MessageHeader *msg) 185 *msg)
188{ 186{
189 struct GNUNET_MessageHeader *m; 187 struct GNUNET_MessageHeader *m;
190 uint16_t size; 188 uint16_t size;
@@ -208,18 +206,18 @@ GNUNET_SERVER_transmit_context_append_message (struct
208 */ 206 */
209void 207void
210GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc, 208GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc,
211 struct GNUNET_TIME_Relative timeout) 209 struct GNUNET_TIME_Relative timeout)
212{ 210{
213 tc->timeout = GNUNET_TIME_relative_to_absolute (timeout); 211 tc->timeout = GNUNET_TIME_relative_to_absolute (timeout);
214 if (NULL == 212 if (NULL ==
215 GNUNET_SERVER_notify_transmit_ready (tc->client, 213 GNUNET_SERVER_notify_transmit_ready (tc->client,
216 GNUNET_MIN (MIN_BLOCK_SIZE, 214 GNUNET_MIN (MIN_BLOCK_SIZE,
217 tc->total), timeout, 215 tc->total), timeout,
218 &transmit_response, tc)) 216 &transmit_response, tc))
219 { 217 {
220 GNUNET_break (0); 218 GNUNET_break (0);
221 GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR); 219 GNUNET_SERVER_transmit_context_destroy (tc, GNUNET_SYSERR);
222 } 220 }
223} 221}
224 222
225 223
@@ -237,7 +235,7 @@ GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc,
237 */ 235 */
238void 236void
239GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContext 237GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContext
240 *tc, int success) 238 *tc, int success)
241{ 239{
242 GNUNET_SERVER_receive_done (tc->client, success); 240 GNUNET_SERVER_receive_done (tc->client, success);
243 GNUNET_SERVER_client_drop (tc->client); 241 GNUNET_SERVER_client_drop (tc->client);