- struct ShutdownContext *shutdown_ctx;
-
- shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext));
- shutdown_ctx->cont = cont;
- shutdown_ctx->cont_cls = cont_cls;
- shutdown_ctx->sock = sock;
- shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
- shutdown_ctx->th = GNUNET_CLIENT_notify_transmit_ready (sock,
- sizeof (struct GNUNET_MessageHeader),
- timeout, GNUNET_NO, &write_shutdown,
- shutdown_ctx);
+ struct GNUNET_ARM_Handle *h = cls;
+ struct GNUNET_ARM_Operation *op;
+ uint64_t id;
+ enum GNUNET_ARM_Result result;
+ GNUNET_ARM_ResultCallback result_cont;
+ void *result_cont_cls;
+
+ id = GNUNET_ntohll (res->arm_msg.request_id);
+ op = find_op_by_id (h,
+ id);
+ if (NULL == op)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Message with unknown id %llu\n",
+ (unsigned long long) id);
+ return;
+ }
+
+ result = (enum GNUNET_ARM_Result) ntohl (res->result);
+ if ( (GNUNET_YES == op->is_arm_stop) &&
+ (GNUNET_ARM_RESULT_STOPPING == result) )
+ {
+ /* special case: if we are stopping 'gnunet-service-arm', we do not just
+ wait for the result message, but also wait for the service to close
+ the connection (and then we have to close our client handle as well);
+ this is done by installing a different receive handler, waiting for
+ the connection to go down */
+ if (NULL != h->thm)
+ {
+ GNUNET_break (0);
+ op->result_cont (h->thm->cont_cls,
+ GNUNET_ARM_REQUEST_SENT_OK,
+ GNUNET_ARM_RESULT_IS_NOT_KNOWN);
+ GNUNET_free (h->thm);
+ }
+ GNUNET_CONTAINER_DLL_remove (h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
+ h->thm = op;
+ return;
+ }
+ result_cont = op->result_cont;
+ result_cont_cls = op->cont_cls;
+ GNUNET_ARM_operation_cancel (op);
+ if (NULL != result_cont)
+ result_cont (result_cont_cls,
+ GNUNET_ARM_REQUEST_SENT_OK,
+ result);