aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_server_with_client_unix.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-05 12:10:06 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-05 12:10:06 +0000
commitb97332aac1d2c14ba8985e82fad90077673027c0 (patch)
tree1873c36b6b27e05335c49c096e0e38a52ea002cb /src/util/test_server_with_client_unix.c
parent0b8a02cc156081ad9a087ea91952a5cfc4270475 (diff)
downloadgnunet-b97332aac1d2c14ba8985e82fad90077673027c0.tar.gz
gnunet-b97332aac1d2c14ba8985e82fad90077673027c0.zip
update remaining tests to use new MQ API
Diffstat (limited to 'src/util/test_server_with_client_unix.c')
-rw-r--r--src/util/test_server_with_client_unix.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c
index 64f1d9c23..ef48aabce 100644
--- a/src/util/test_server_with_client_unix.c
+++ b/src/util/test_server_with_client_unix.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009 GNUnet e.V. 3 Copyright (C) 2009, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -31,7 +31,7 @@
31 31
32static struct GNUNET_SERVER_Handle *server; 32static struct GNUNET_SERVER_Handle *server;
33 33
34static struct GNUNET_CLIENT_Connection *client; 34static struct GNUNET_MQ_Handle *mq;
35 35
36static struct GNUNET_CONFIGURATION_Handle *cfg; 36static struct GNUNET_CONFIGURATION_Handle *cfg;
37 37
@@ -65,7 +65,7 @@ recv_cb (void *cls,
65 break; 65 break;
66 case 4: 66 case 4:
67 ok++; 67 ok++;
68 GNUNET_CLIENT_disconnect (client); 68 GNUNET_MQ_destroy (mq);
69 GNUNET_SERVER_receive_done (argclient, GNUNET_OK); 69 GNUNET_SERVER_receive_done (argclient, GNUNET_OK);
70 break; 70 break;
71 default: 71 default:
@@ -104,24 +104,6 @@ notify_disconnect (void *cls,
104} 104}
105 105
106 106
107static size_t
108notify_ready (void *cls, size_t size, void *buf)
109{
110 struct GNUNET_MessageHeader *msg;
111
112 GNUNET_assert (size >= 256);
113 GNUNET_assert (1 == ok);
114 ok++;
115 msg = buf;
116 msg->type = htons (MY_TYPE);
117 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
118 msg++;
119 msg->type = htons (MY_TYPE);
120 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
121 return 2 * sizeof (struct GNUNET_MessageHeader);
122}
123
124
125static struct GNUNET_SERVER_MessageHandler handlers[] = { 107static struct GNUNET_SERVER_MessageHandler handlers[] = {
126 {&recv_cb, NULL, MY_TYPE, sizeof (struct GNUNET_MessageHeader)}, 108 {&recv_cb, NULL, MY_TYPE, sizeof (struct GNUNET_MessageHeader)},
127 {NULL, NULL, 0, 0} 109 {NULL, NULL, 0, 0}
@@ -135,6 +117,8 @@ task (void *cls)
135 const char *unixpath = "/tmp/testsock"; 117 const char *unixpath = "/tmp/testsock";
136 struct sockaddr *sap[2]; 118 struct sockaddr *sap[2];
137 socklen_t slens[2]; 119 socklen_t slens[2];
120 struct GNUNET_MQ_Envelope *env;
121 struct GNUNET_MessageHeader *msg;
138 122
139 memset (&un, 0, sizeof (un)); 123 memset (&un, 0, sizeof (un));
140 un.sun_family = AF_UNIX; 124 un.sun_family = AF_UNIX;
@@ -160,13 +144,21 @@ task (void *cls)
160 GNUNET_CONFIGURATION_set_value_string (cfg, "test", "UNIXPATH", unixpath); 144 GNUNET_CONFIGURATION_set_value_string (cfg, "test", "UNIXPATH", unixpath);
161 GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", 145 GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME",
162 "localhost"); 146 "localhost");
163 147 mq = GNUNET_CLIENT_connecT (cfg,
164 client = GNUNET_CLIENT_connect ("test", cfg); 148 "test",
165 GNUNET_assert (client != NULL); 149 NULL,
166 GNUNET_CLIENT_notify_transmit_ready (client, 256, 150 NULL,
167 GNUNET_TIME_relative_multiply 151 NULL);
168 (GNUNET_TIME_UNIT_MILLISECONDS, 250), 152 GNUNET_assert (NULL != mq);
169 GNUNET_NO, &notify_ready, NULL); 153 ok = 2;
154 env = GNUNET_MQ_msg (msg,
155 MY_TYPE);
156 GNUNET_MQ_send (mq,
157 env);
158 env = GNUNET_MQ_msg (msg,
159 MY_TYPE);
160 GNUNET_MQ_send (mq,
161 env);
170} 162}
171 163
172 164