aboutsummaryrefslogtreecommitdiff
path: root/src/util/client_new.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/client_new.c')
-rw-r--r--src/util/client_new.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/util/client_new.c b/src/util/client_new.c
index 1e90470fb..593d3a268 100644
--- a/src/util/client_new.c
+++ b/src/util/client_new.c
@@ -213,10 +213,9 @@ start_connect (void *cls);
213static void 213static void
214connect_fail_continuation (struct ClientState *cstate) 214connect_fail_continuation (struct ClientState *cstate)
215{ 215{
216 LOG (GNUNET_ERROR_TYPE_INFO, 216 LOG (GNUNET_ERROR_TYPE_WARNING,
217 "Failed to establish TCP connection to `%s:%u', no further addresses to try.\n", 217 "Failed to establish connection to `%s', no further addresses to try.\n",
218 cstate->hostname, 218 cstate->service_name);
219 cstate->port);
220 GNUNET_break (NULL == cstate->ap_head); 219 GNUNET_break (NULL == cstate->ap_head);
221 GNUNET_break (NULL == cstate->ap_tail); 220 GNUNET_break (NULL == cstate->ap_tail);
222 GNUNET_break (NULL == cstate->dns_active); 221 GNUNET_break (NULL == cstate->dns_active);
@@ -245,6 +244,7 @@ transmit_ready (void *cls)
245 ssize_t ret; 244 ssize_t ret;
246 size_t len; 245 size_t len;
247 const char *pos; 246 const char *pos;
247 int notify_in_flight;
248 248
249 cstate->send_task = NULL; 249 cstate->send_task = NULL;
250 pos = (const char *) cstate->msg; 250 pos = (const char *) cstate->msg;
@@ -262,10 +262,7 @@ transmit_ready (void *cls)
262 GNUNET_MQ_ERROR_WRITE); 262 GNUNET_MQ_ERROR_WRITE);
263 return; 263 return;
264 } 264 }
265 if (0 == cstate->msg_off) 265 notify_in_flight = (0 == cstate->msg_off);
266 {
267 GNUNET_MQ_impl_send_in_flight (cstate->mq);
268 }
269 cstate->msg_off += ret; 266 cstate->msg_off += ret;
270 if (cstate->msg_off < len) 267 if (cstate->msg_off < len)
271 { 268 {
@@ -274,6 +271,8 @@ transmit_ready (void *cls)
274 cstate->sock, 271 cstate->sock,
275 &transmit_ready, 272 &transmit_ready,
276 cstate); 273 cstate);
274 if (notify_in_flight)
275 GNUNET_MQ_impl_send_in_flight (cstate->mq);
277 return; 276 return;
278 } 277 }
279 cstate->msg = NULL; 278 cstate->msg = NULL;
@@ -345,6 +344,7 @@ connection_client_destroy_impl (struct GNUNET_MQ_Handle *mq,
345 { 344 {
346 /* defer destruction */ 345 /* defer destruction */
347 cstate->in_destroy = GNUNET_YES; 346 cstate->in_destroy = GNUNET_YES;
347 cstate->mq = NULL;
348 return; 348 return;
349 } 349 }
350 if (NULL != cstate->dns_active) 350 if (NULL != cstate->dns_active)
@@ -384,8 +384,12 @@ receive_ready (void *cls)
384 GNUNET_NO); 384 GNUNET_NO);
385 if (GNUNET_SYSERR == ret) 385 if (GNUNET_SYSERR == ret)
386 { 386 {
387 GNUNET_MQ_inject_error (cstate->mq, 387 if (NULL != cstate->mq)
388 GNUNET_MQ_ERROR_READ); 388 GNUNET_MQ_inject_error (cstate->mq,
389 GNUNET_MQ_ERROR_READ);
390 if (GNUNET_YES == cstate->in_destroy)
391 connection_client_destroy_impl (cstate->mq,
392 cstate);
389 return; 393 return;
390 } 394 }
391 if (GNUNET_YES == cstate->in_destroy) 395 if (GNUNET_YES == cstate->in_destroy)
@@ -723,16 +727,25 @@ start_connect (void *cls)
723#endif 727#endif
724 728
725 if ( (0 == (cstate->attempts++ % 2)) || 729 if ( (0 == (cstate->attempts++ % 2)) ||
726 (0 == cstate->port) ) 730 (0 == cstate->port) ||
731 (NULL == cstate->hostname) )
727 { 732 {
728 /* on even rounds, try UNIX first */ 733 /* on even rounds, try UNIX first, or always
734 if we do not have a DNS name and TCP port. */
729 cstate->sock = try_unixpath (cstate->service_name, 735 cstate->sock = try_unixpath (cstate->service_name,
730 cstate->cfg); 736 cstate->cfg);
731 if (NULL != cstate->sock) 737 if (NULL != cstate->sock)
732 { 738 {
733 connect_success_continuation (cstate); 739 connect_success_continuation (cstate);
734 return; 740 return;
735 } 741 }
742 }
743 if ( (NULL == cstate->hostname) ||
744 (0 == cstate->port) )
745 {
746 /* All options failed. Boo! */
747 connect_fail_continuation (cstate);
748 return;
736 } 749 }
737 cstate->dns_active 750 cstate->dns_active
738 = GNUNET_RESOLVER_ip_get (cstate->hostname, 751 = GNUNET_RESOLVER_ip_get (cstate->hostname,
@@ -807,11 +820,11 @@ connection_client_cancel_impl (struct GNUNET_MQ_Handle *mq,
807 * @return the message queue, NULL on error 820 * @return the message queue, NULL on error
808 */ 821 */
809struct GNUNET_MQ_Handle * 822struct GNUNET_MQ_Handle *
810GNUNET_CLIENT_connecT2 (const struct GNUNET_CONFIGURATION_Handle *cfg, 823GNUNET_CLIENT_connecT (const struct GNUNET_CONFIGURATION_Handle *cfg,
811 const char *service_name, 824 const char *service_name,
812 const struct GNUNET_MQ_MessageHandler *handlers, 825 const struct GNUNET_MQ_MessageHandler *handlers,
813 GNUNET_MQ_ErrorHandler error_handler, 826 GNUNET_MQ_ErrorHandler error_handler,
814 void *error_handler_cls) 827 void *error_handler_cls)
815{ 828{
816 struct ClientState *cstate; 829 struct ClientState *cstate;
817 830