aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-cadet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/gnunet-cadet.c')
-rw-r--r--src/cadet/gnunet-cadet.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index 67cebf02b..b22881907 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -27,6 +27,7 @@
27#include "gnunet_cadet_service.h" 27#include "gnunet_cadet_service.h"
28#include "cadet.h" 28#include "cadet.h"
29 29
30#define STREAM_BUFFER_SIZE 1024 // Pakets
30 31
31/** 32/**
32 * Option -P. 33 * Option -P.
@@ -123,6 +124,8 @@ static struct GNUNET_SCHEDULER_Task *rd_task;
123 */ 124 */
124static struct GNUNET_SCHEDULER_Task *job; 125static struct GNUNET_SCHEDULER_Task *job;
125 126
127static unsigned int sent_pkt;
128
126 129
127/** 130/**
128 * Wait for input on STDIO and send it out over the #ch. 131 * Wait for input on STDIO and send it out over the #ch.
@@ -228,6 +231,12 @@ shutdown_task (void *cls)
228 } 231 }
229} 232}
230 233
234void *
235mq_cb(void *cls)
236{
237 listen_stdio ();
238}
239
231 240
232/** 241/**
233 * Task run in stdio mode, after some data is available at stdin. 242 * Task run in stdio mode, after some data is available at stdin.
@@ -248,6 +257,8 @@ read_stdio (void *cls)
248 60000); 257 60000);
249 if (data_size < 1) 258 if (data_size < 1)
250 { 259 {
260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
261 "read() returned %s\n", strerror(errno));
251 GNUNET_SCHEDULER_shutdown(); 262 GNUNET_SCHEDULER_shutdown();
252 return; 263 return;
253 } 264 }
@@ -262,9 +273,21 @@ read_stdio (void *cls)
262 data_size); 273 data_size);
263 GNUNET_MQ_send (GNUNET_CADET_get_mq (ch), 274 GNUNET_MQ_send (GNUNET_CADET_get_mq (ch),
264 env); 275 env);
276
277 sent_pkt++;
278
265 if (GNUNET_NO == echo) 279 if (GNUNET_NO == echo)
266 { 280 {
267 listen_stdio (); 281 // Use MQ's notification if too much data of stdin is pooring in too fast.
282 if (STREAM_BUFFER_SIZE < sent_pkt)
283 {
284 GNUNET_MQ_notify_sent (env, mq_cb, cls);
285 sent_pkt = 0;
286 }
287 else
288 {
289 listen_stdio ();
290 }
268 } 291 }
269 else 292 else
270 { 293 {