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.c77
1 files changed, 40 insertions, 37 deletions
diff --git a/src/util/server_tc.c b/src/util/server_tc.c
index b7158dadb..eda82e50f 100644
--- a/src/util/server_tc.c
+++ b/src/util/server_tc.c
@@ -79,14 +79,15 @@ transmit_response (void *cls, size_t size, void *buf)
79{ 79{
80 struct GNUNET_SERVER_TransmitContext *tc = cls; 80 struct GNUNET_SERVER_TransmitContext *tc = cls;
81 size_t msize; 81 size_t msize;
82
82 if (buf == NULL) 83 if (buf == NULL)
83 { 84 {
84 GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR); 85 GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR);
85 GNUNET_SERVER_client_drop (tc->client); 86 GNUNET_SERVER_client_drop (tc->client);
86 GNUNET_free_non_null (tc->buf); 87 GNUNET_free_non_null (tc->buf);
87 GNUNET_free (tc); 88 GNUNET_free (tc);
88 return 0; 89 return 0;
89 } 90 }
90 if (tc->total - tc->off > size) 91 if (tc->total - tc->off > size)
91 msize = size; 92 msize = size;
92 else 93 else
@@ -94,30 +95,29 @@ transmit_response (void *cls, size_t size, void *buf)
94 memcpy (buf, &tc->buf[tc->off], msize); 95 memcpy (buf, &tc->buf[tc->off], msize);
95 tc->off += msize; 96 tc->off += msize;
96 if (tc->total == tc->off) 97 if (tc->total == tc->off)
98 {
99 GNUNET_SERVER_receive_done (tc->client, GNUNET_OK);
100 GNUNET_SERVER_client_drop (tc->client);
101 GNUNET_free_non_null (tc->buf);
102 GNUNET_free (tc);
103 }
104 else
105 {
106 if (NULL == GNUNET_SERVER_notify_transmit_ready (tc->client,
107 GNUNET_MIN
108 (MIN_BLOCK_SIZE,
109 tc->total - tc->off),
110 GNUNET_TIME_absolute_get_remaining
111 (tc->timeout),
112 &transmit_response, tc))
97 { 113 {
98 GNUNET_SERVER_receive_done (tc->client, GNUNET_OK); 114 GNUNET_break (0);
115 GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR);
99 GNUNET_SERVER_client_drop (tc->client); 116 GNUNET_SERVER_client_drop (tc->client);
100 GNUNET_free_non_null (tc->buf); 117 GNUNET_free_non_null (tc->buf);
101 GNUNET_free (tc); 118 GNUNET_free (tc);
102 } 119 }
103 else 120 }
104 {
105 if (NULL == GNUNET_SERVER_notify_transmit_ready (tc->client,
106 GNUNET_MIN
107 (MIN_BLOCK_SIZE,
108 tc->total - tc->off),
109 GNUNET_TIME_absolute_get_remaining
110 (tc->timeout),
111 &transmit_response,
112 tc))
113 {
114 GNUNET_break (0);
115 GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR);
116 GNUNET_SERVER_client_drop (tc->client);
117 GNUNET_free_non_null (tc->buf);
118 GNUNET_free (tc);
119 }
120 }
121 return msize; 121 return msize;
122} 122}
123 123
@@ -154,8 +154,8 @@ GNUNET_SERVER_transmit_context_create (struct GNUNET_SERVER_Client *client)
154 */ 154 */
155void 155void
156GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitContext 156GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitContext
157 *tc, const void *data, size_t length, 157 *tc, const void *data,
158 uint16_t type) 158 size_t length, uint16_t type)
159{ 159{
160 struct GNUNET_MessageHeader *msg; 160 struct GNUNET_MessageHeader *msg;
161 size_t size; 161 size_t size;
@@ -181,8 +181,11 @@ GNUNET_SERVER_transmit_context_append_data (struct GNUNET_SERVER_TransmitContext
181 * @param msg message to append 181 * @param msg message to append
182 */ 182 */
183void 183void
184GNUNET_SERVER_transmit_context_append_message(struct GNUNET_SERVER_TransmitContext 184GNUNET_SERVER_transmit_context_append_message (struct
185 *tc, const struct GNUNET_MessageHeader *msg) 185 GNUNET_SERVER_TransmitContext
186 *tc,
187 const struct GNUNET_MessageHeader
188 *msg)
186{ 189{
187 struct GNUNET_MessageHeader *m; 190 struct GNUNET_MessageHeader *m;
188 uint16_t size; 191 uint16_t size;
@@ -214,13 +217,13 @@ GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc,
214 GNUNET_MIN (MIN_BLOCK_SIZE, 217 GNUNET_MIN (MIN_BLOCK_SIZE,
215 tc->total), timeout, 218 tc->total), timeout,
216 &transmit_response, tc)) 219 &transmit_response, tc))
217 { 220 {
218 GNUNET_break (0); 221 GNUNET_break (0);
219 GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR); 222 GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR);
220 GNUNET_SERVER_client_drop (tc->client); 223 GNUNET_SERVER_client_drop (tc->client);
221 GNUNET_free_non_null (tc->buf); 224 GNUNET_free_non_null (tc->buf);
222 GNUNET_free (tc); 225 GNUNET_free (tc);
223 } 226 }
224} 227}
225 228
226/* end of server_tc.c */ 229/* end of server_tc.c */