aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_service.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-04-25 14:45:39 +0000
committerChristian Grothoff <christian@grothoff.org>2012-04-25 14:45:39 +0000
commitaf7547fbce7e27513d862c0098fbcb5bdfb678b9 (patch)
tree92860841f44547365ac9813f69e4d81dbc2aba70 /src/util/test_service.c
parent026b222dbbe038ce894c0ba33aa3c40950f6aecd (diff)
downloadgnunet-af7547fbce7e27513d862c0098fbcb5bdfb678b9.tar.gz
gnunet-af7547fbce7e27513d862c0098fbcb5bdfb678b9.zip
-handle timeout better
Diffstat (limited to 'src/util/test_service.c')
-rw-r--r--src/util/test_service.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/util/test_service.c b/src/util/test_service.c
index cd73ceee4..92aefc63f 100644
--- a/src/util/test_service.c
+++ b/src/util/test_service.c
@@ -44,11 +44,31 @@ static int ok = 1;
44static struct GNUNET_CLIENT_Connection *client; 44static struct GNUNET_CLIENT_Connection *client;
45 45
46 46
47
48
49static void
50do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
51{
52 GNUNET_CLIENT_disconnect (client);
53 client = NULL;
54 GNUNET_SERVICE_stop (sctx);
55 sctx = NULL;
56}
57
58
47static size_t 59static size_t
48build_msg (void *cls, size_t size, void *buf) 60build_msg (void *cls, size_t size, void *buf)
49{ 61{
50 struct GNUNET_MessageHeader *msg = buf; 62 struct GNUNET_MessageHeader *msg = buf;
51 63
64 if (size < sizeof (struct GNUNET_MessageHeader))
65 {
66 /* timeout */
67 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
68 ok = 1;
69 return 0;
70 }
71
52 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connected, transmitting\n"); 72 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connected, transmitting\n");
53 GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); 73 GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
54 msg->type = htons (MY_TYPE); 74 msg->type = htons (MY_TYPE);
@@ -76,14 +96,6 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
76 96
77 97
78static void 98static void
79do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
80{
81 GNUNET_CLIENT_disconnect (client);
82 GNUNET_SERVICE_stop (sctx);
83}
84
85
86static void
87recv_cb (void *cls, struct GNUNET_SERVER_Client *sc, 99recv_cb (void *cls, struct GNUNET_SERVER_Client *sc,
88 const struct GNUNET_MessageHeader *message) 100 const struct GNUNET_MessageHeader *message)
89{ 101{