diff options
Diffstat (limited to 'src/arm/arm_api.c')
-rw-r--r-- | src/arm/arm_api.c | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index f2992b38a..d6b65e872 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -87,11 +87,6 @@ struct ShutdownContext | |||
87 | */ | 87 | */ |
88 | struct GNUNET_CLIENT_TransmitHandle *th; | 88 | struct GNUNET_CLIENT_TransmitHandle *th; |
89 | 89 | ||
90 | /** | ||
91 | * Result of the operation | ||
92 | */ | ||
93 | enum GNUNET_ARM_ProcessStatus confirmed; | ||
94 | |||
95 | }; | 90 | }; |
96 | 91 | ||
97 | 92 | ||
@@ -110,37 +105,23 @@ static void | |||
110 | service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | 105 | service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) |
111 | { | 106 | { |
112 | struct ShutdownContext *shutdown_ctx = cls; | 107 | struct ShutdownContext *shutdown_ctx = cls; |
113 | const struct GNUNET_ARM_ResultMessage *rmsg; | ||
114 | 108 | ||
115 | if (msg == NULL) | 109 | if (NULL != msg) |
116 | { | 110 | { |
117 | if (shutdown_ctx->cont != NULL) | 111 | /* We just expected a disconnect! Report the error and be done with it... */ |
118 | { | 112 | GNUNET_break (0); |
119 | /* shutdown is now complete, as we waited for the network disconnect... */ | 113 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR); |
120 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_DOWN); | ||
121 | } | ||
122 | GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task); | 114 | GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task); |
123 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock); | 115 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock); |
124 | GNUNET_free (shutdown_ctx); | 116 | GNUNET_free (shutdown_ctx); |
125 | return; | 117 | return; |
126 | } | 118 | } |
127 | if (ntohs (msg->size) == | 119 | if (NULL != shutdown_ctx->cont) |
128 | sizeof (struct GNUNET_ARM_ResultMessage)) | 120 | /* shutdown is now complete, as we waited for the network disconnect... */ |
129 | { | 121 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_DOWN); |
130 | rmsg = (const struct GNUNET_ARM_ResultMessage*) msg; | 122 | GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task); |
131 | shutdown_ctx->confirmed = (enum GNUNET_ARM_ProcessStatus) ntohl (rmsg->status); | 123 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock); |
132 | if (shutdown_ctx->confirmed != GNUNET_ARM_PROCESS_SHUTDOWN) | 124 | GNUNET_free (shutdown_ctx); |
133 | { | ||
134 | /* ARM is not shutting down, well, report the error and be done with it... */ | ||
135 | shutdown_ctx->cont (shutdown_ctx->cont_cls, shutdown_ctx->confirmed); | ||
136 | GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task); | ||
137 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock); | ||
138 | GNUNET_free (shutdown_ctx); | ||
139 | return; | ||
140 | } | ||
141 | } | ||
142 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, | ||
143 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); | ||
144 | } | 125 | } |
145 | 126 | ||
146 | 127 | ||
@@ -225,7 +206,6 @@ arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, | |||
225 | shutdown_ctx->cont_cls = cont_cls; | 206 | shutdown_ctx->cont_cls = cont_cls; |
226 | shutdown_ctx->sock = sock; | 207 | shutdown_ctx->sock = sock; |
227 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 208 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
228 | shutdown_ctx->confirmed = GNUNET_ARM_PROCESS_COMMUNICATION_ERROR; | ||
229 | shutdown_ctx->th = GNUNET_CLIENT_notify_transmit_ready (sock, | 209 | shutdown_ctx->th = GNUNET_CLIENT_notify_transmit_ready (sock, |
230 | sizeof (struct GNUNET_MessageHeader), | 210 | sizeof (struct GNUNET_MessageHeader), |
231 | timeout, GNUNET_NO, &write_shutdown, | 211 | timeout, GNUNET_NO, &write_shutdown, |