aboutsummaryrefslogtreecommitdiff
path: root/src/util/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/client.c')
-rw-r--r--src/util/client.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/util/client.c b/src/util/client.c
index f93fd1d10..d00e8bbd0 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -578,7 +578,7 @@ receive_helper (void *cls,
578/** 578/**
579 * Continuation to call the receive callback. 579 * Continuation to call the receive callback.
580 * 580 *
581 * @param cls our handle to the client connection 581 * @param cls our handle to the client connection
582 */ 582 */
583static void 583static void
584receive_task (void *cls) 584receive_task (void *cls)
@@ -611,7 +611,8 @@ receive_task (void *cls)
611 GNUNET_assert (GNUNET_YES == client->msg_complete); 611 GNUNET_assert (GNUNET_YES == client->msg_complete);
612 GNUNET_assert (client->received_pos >= msize); 612 GNUNET_assert (client->received_pos >= msize);
613 memcpy (msg, cmsg, msize); 613 memcpy (msg, cmsg, msize);
614 memmove (client->received_buf, &client->received_buf[msize], 614 memmove (client->received_buf,
615 &client->received_buf[msize],
615 client->received_pos - msize); 616 client->received_pos - msize);
616 client->received_pos -= msize; 617 client->received_pos -= msize;
617 client->msg_complete = GNUNET_NO; 618 client->msg_complete = GNUNET_NO;
@@ -655,7 +656,8 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *client,
655 (GNUNET_SYSERR == client->in_receive) ) 656 (GNUNET_SYSERR == client->in_receive) )
656 { 657 {
657 GNUNET_assert (NULL == client->receive_task); 658 GNUNET_assert (NULL == client->receive_task);
658 client->receive_task = GNUNET_SCHEDULER_add_now (&receive_task, client); 659 client->receive_task = GNUNET_SCHEDULER_add_now (&receive_task,
660 client);
659 return; 661 return;
660 } 662 }
661 LOG (GNUNET_ERROR_TYPE_DEBUG, 663 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -703,7 +705,7 @@ struct GNUNET_CLIENT_TestHandle
703 /** 705 /**
704 * ID of task used for asynchronous operations. 706 * ID of task used for asynchronous operations.
705 */ 707 */
706 struct GNUNET_SCHEDULER_Task * task; 708 struct GNUNET_SCHEDULER_Task *task;
707 709
708 /** 710 /**
709 * Final result to report back (once known). 711 * Final result to report back (once known).
@@ -1081,19 +1083,9 @@ static void
1081client_delayed_retry (void *cls) 1083client_delayed_retry (void *cls)
1082{ 1084{
1083 struct GNUNET_CLIENT_TransmitHandle *th = cls; 1085 struct GNUNET_CLIENT_TransmitHandle *th = cls;
1084 const struct GNUNET_SCHEDULER_TaskContext *tc;
1085 struct GNUNET_TIME_Relative delay; 1086 struct GNUNET_TIME_Relative delay;
1086 1087
1087 th->reconnect_task = NULL; 1088 th->reconnect_task = NULL;
1088 tc = GNUNET_SCHEDULER_get_task_context ();
1089 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1090 {
1091 /* give up, was shutdown */
1092 th->client->th = NULL;
1093 th->notify (th->notify_cls, 0, NULL);
1094 GNUNET_free (th);
1095 return;
1096 }
1097 th->client->connection = 1089 th->client->connection =
1098 do_connect (th->client->service_name, 1090 do_connect (th->client->service_name,
1099 th->client->cfg, 1091 th->client->cfg,
@@ -1112,13 +1104,16 @@ client_delayed_retry (void *cls)
1112 GNUNET_assert (NULL == th->th); 1104 GNUNET_assert (NULL == th->th);
1113 GNUNET_assert (NULL == th->reconnect_task); 1105 GNUNET_assert (NULL == th->reconnect_task);
1114 th->reconnect_task = 1106 th->reconnect_task =
1115 GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); 1107 GNUNET_SCHEDULER_add_delayed (delay,
1108 &client_delayed_retry,
1109 th);
1116 return; 1110 return;
1117 } 1111 }
1118 th->th = 1112 th->th =
1119 GNUNET_CONNECTION_notify_transmit_ready (th->client->connection, th->size, 1113 GNUNET_CONNECTION_notify_transmit_ready (th->client->connection, th->size,
1120 GNUNET_TIME_absolute_get_remaining 1114 GNUNET_TIME_absolute_get_remaining
1121 (th->timeout), &client_notify, 1115 (th->timeout),
1116 &client_notify,
1122 th); 1117 th);
1123 if (NULL == th->th) 1118 if (NULL == th->th)
1124 { 1119 {
@@ -1149,22 +1144,18 @@ client_notify (void *cls,
1149 struct GNUNET_CLIENT_Connection *client = th->client; 1144 struct GNUNET_CLIENT_Connection *client = th->client;
1150 size_t ret; 1145 size_t ret;
1151 struct GNUNET_TIME_Relative delay; 1146 struct GNUNET_TIME_Relative delay;
1152 const struct GNUNET_SCHEDULER_TaskContext *tc;
1153
1154 1147
1155 LOG (GNUNET_ERROR_TYPE_DEBUG, 1148 LOG (GNUNET_ERROR_TYPE_DEBUG,
1156 "client_notify is running\n"); 1149 "client_notify is running\n");
1157 th->th = NULL; 1150 th->th = NULL;
1158 client->th = NULL; 1151 client->th = NULL;
1159 tc = GNUNET_SCHEDULER_get_task_context ();
1160 if (NULL == buf) 1152 if (NULL == buf)
1161 { 1153 {
1162 delay = GNUNET_TIME_absolute_get_remaining (th->timeout); 1154 delay = GNUNET_TIME_absolute_get_remaining (th->timeout);
1163 delay.rel_value_us /= 2; 1155 delay.rel_value_us /= 2;
1164 if ( (GNUNET_YES != th->auto_retry) || 1156 if ( (GNUNET_YES != th->auto_retry) ||
1165 (0 == --th->attempts_left) || 1157 (0 == --th->attempts_left) ||
1166 (delay.rel_value_us < 1)|| 1158 (delay.rel_value_us < 1) )
1167 (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
1168 { 1159 {
1169 LOG (GNUNET_ERROR_TYPE_DEBUG, 1160 LOG (GNUNET_ERROR_TYPE_DEBUG,
1170 "Transmission failed %u times, giving up.\n", 1161 "Transmission failed %u times, giving up.\n",
@@ -1198,7 +1189,9 @@ client_notify (void *cls,
1198 GNUNET_assert (NULL == th->reconnect_task); 1189 GNUNET_assert (NULL == th->reconnect_task);
1199 GNUNET_assert (NULL == th->th); 1190 GNUNET_assert (NULL == th->th);
1200 th->reconnect_task = 1191 th->reconnect_task =
1201 GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); 1192 GNUNET_SCHEDULER_add_delayed (delay,
1193 &client_delayed_retry,
1194 th);
1202 return 0; 1195 return 0;
1203 } 1196 }
1204 GNUNET_assert (size >= th->size); 1197 GNUNET_assert (size >= th->size);