aboutsummaryrefslogtreecommitdiff
path: root/src/util/client.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-09-11 19:22:36 +0000
committerChristian Grothoff <christian@grothoff.org>2016-09-11 19:22:36 +0000
commit17987cc9db00b169dd8bff5a620e5d5ab51ff044 (patch)
tree4fddeea70da412adb85070115fd7cbdc462412aa /src/util/client.c
parent360b57d787c60c436ca7e103c18f9633e5cbe4c6 (diff)
downloadgnunet-17987cc9db00b169dd8bff5a620e5d5ab51ff044.tar.gz
gnunet-17987cc9db00b169dd8bff5a620e5d5ab51ff044.zip
kill dead code
Diffstat (limited to 'src/util/client.c')
-rw-r--r--src/util/client.c141
1 files changed, 0 insertions, 141 deletions
diff --git a/src/util/client.c b/src/util/client.c
index 0ab16a9a1..f40d5e6eb 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -101,39 +101,6 @@ struct GNUNET_CLIENT_TransmitHandle
101 101
102 102
103/** 103/**
104 * Context for processing
105 * "GNUNET_CLIENT_transmit_and_get_response" requests.
106 */
107struct TransmitGetResponseContext
108{
109 /**
110 * Client handle.
111 */
112 struct GNUNET_CLIENT_Connection *client;
113
114 /**
115 * Message to transmit; do not free, allocated
116 * right after this struct.
117 */
118 const struct GNUNET_MessageHeader *hdr;
119
120 /**
121 * Timeout to use.
122 */
123 struct GNUNET_TIME_Absolute timeout;
124
125 /**
126 * Function to call when done.
127 */
128 GNUNET_CLIENT_MessageHandler rn;
129
130 /**
131 * Closure for @e rn.
132 */
133 void *rn_cls;
134};
135
136/**
137 * Struct to refer to a GNUnet TCP connection. 104 * Struct to refer to a GNUnet TCP connection.
138 * This is more than just a socket because if the server 105 * This is more than just a socket because if the server
139 * drops the connection, the client automatically tries 106 * drops the connection, the client automatically tries
@@ -158,12 +125,6 @@ struct GNUNET_CLIENT_Connection
158 char *service_name; 125 char *service_name;
159 126
160 /** 127 /**
161 * Context of a transmit_and_get_response operation, NULL
162 * if no such operation is pending.
163 */
164 struct TransmitGetResponseContext *tag;
165
166 /**
167 * Handler for current receiver task. 128 * Handler for current receiver task.
168 */ 129 */
169 GNUNET_CLIENT_MessageHandler receiver_handler; 130 GNUNET_CLIENT_MessageHandler receiver_handler;
@@ -499,11 +460,6 @@ GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *client)
499 GNUNET_SCHEDULER_cancel (client->receive_task); 460 GNUNET_SCHEDULER_cancel (client->receive_task);
500 client->receive_task = NULL; 461 client->receive_task = NULL;
501 } 462 }
502 if (NULL != client->tag)
503 {
504 GNUNET_free (client->tag);
505 client->tag = NULL;
506 }
507 client->receiver_handler = NULL; 463 client->receiver_handler = NULL;
508 GNUNET_array_grow (client->received_buf, 464 GNUNET_array_grow (client->received_buf,
509 client->received_size, 465 client->received_size,
@@ -1340,101 +1296,4 @@ GNUNET_CLIENT_notify_transmit_ready_cancel (struct GNUNET_CLIENT_TransmitHandle
1340} 1296}
1341 1297
1342 1298
1343/**
1344 * Function called to notify a client about the socket
1345 * begin ready to queue the message. @a buf will be
1346 * NULL and @a size zero if the socket was closed for
1347 * writing in the meantime.
1348 *
1349 * @param cls closure of type `struct TransmitGetResponseContext *`
1350 * @param size number of bytes available in @a buf
1351 * @param buf where the callee should write the message
1352 * @return number of bytes written to @a buf
1353 */
1354static size_t
1355transmit_for_response (void *cls,
1356 size_t size,
1357 void *buf)
1358{
1359 struct TransmitGetResponseContext *tc = cls;
1360 uint16_t msize;
1361
1362 tc->client->tag = NULL;
1363 msize = ntohs (tc->hdr->size);
1364 if (NULL == buf)
1365 {
1366 LOG (GNUNET_ERROR_TYPE_DEBUG,
1367 "Could not submit request, not expecting to receive a response.\n");
1368 if (NULL != tc->rn)
1369 tc->rn (tc->rn_cls, NULL);
1370 GNUNET_free (tc);
1371 return 0;
1372 }
1373 GNUNET_assert (size >= msize);
1374 GNUNET_memcpy (buf, tc->hdr, msize);
1375 GNUNET_CLIENT_receive (tc->client,
1376 tc->rn,
1377 tc->rn_cls,
1378 GNUNET_TIME_absolute_get_remaining (tc->timeout));
1379 GNUNET_free (tc);
1380 return msize;
1381}
1382
1383
1384/**
1385 * Convenience API that combines sending a request
1386 * to the service and waiting for a response.
1387 * If either operation times out, the callback
1388 * will be called with a "NULL" response (in which
1389 * case the connection should probably be destroyed).
1390 *
1391 * @param client connection to use
1392 * @param hdr message to transmit
1393 * @param timeout when to give up (for both transmission
1394 * and for waiting for a response)
1395 * @param auto_retry if the connection to the service dies, should we
1396 * automatically re-connect and retry (within the timeout period)
1397 * or should we immediately fail in this case? Pass GNUNET_YES
1398 * if the caller does not care about temporary connection errors,
1399 * for example because the protocol is stateless
1400 * @param rn function to call with the response
1401 * @param rn_cls closure for @a rn
1402 * @return #GNUNET_OK on success, #GNUNET_SYSERR if a request
1403 * is already pending
1404 */
1405int
1406GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *client,
1407 const struct GNUNET_MessageHeader *hdr,
1408 struct GNUNET_TIME_Relative timeout,
1409 int auto_retry,
1410 GNUNET_CLIENT_MessageHandler rn,
1411 void *rn_cls)
1412{
1413 struct TransmitGetResponseContext *tc;
1414 uint16_t msize;
1415
1416 if (NULL != client->th)
1417 return GNUNET_SYSERR;
1418 GNUNET_assert (NULL == client->tag);
1419 msize = ntohs (hdr->size);
1420 tc = GNUNET_malloc (sizeof (struct TransmitGetResponseContext) + msize);
1421 tc->client = client;
1422 tc->hdr = (const struct GNUNET_MessageHeader *) &tc[1];
1423 GNUNET_memcpy (&tc[1], hdr, msize);
1424 tc->timeout = GNUNET_TIME_relative_to_absolute (timeout);
1425 tc->rn = rn;
1426 tc->rn_cls = rn_cls;
1427 if (NULL ==
1428 GNUNET_CLIENT_notify_transmit_ready (client, msize, timeout, auto_retry,
1429 &transmit_for_response, tc))
1430 {
1431 GNUNET_break (0);
1432 GNUNET_free (tc);
1433 return GNUNET_SYSERR;
1434 }
1435 client->tag = tc;
1436 return GNUNET_OK;
1437}
1438
1439
1440/* end of client.c */ 1299/* end of client.c */