[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11308 - in gnunet/src: arm include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11308 - in gnunet/src: arm include util |
Date: |
Tue, 11 May 2010 15:06:16 +0200 |
Author: grothoff
Date: 2010-05-11 15:06:16 +0200 (Tue, 11 May 2010)
New Revision: 11308
Modified:
gnunet/src/arm/gnunet-service-arm.c
gnunet/src/arm/mockup-service.c
gnunet/src/include/gnunet_protocols.h
gnunet/src/util/client.c
gnunet/src/util/service.c
Log:
arm-specific
Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2010-05-11 13:02:29 UTC (rev 11307)
+++ gnunet/src/arm/gnunet-service-arm.c 2010-05-11 13:06:16 UTC (rev 11308)
@@ -966,12 +966,64 @@
}
+static size_t
+transmit_shutdown_ack (void *cls, size_t size, void *buf)
+{
+ struct GNUNET_SERVER_Client *client = cls;
+ struct GNUNET_MessageHeader *msg;
+
+ if (size < sizeof (struct GNUNET_MessageHeader))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Failed to transmit shutdown ACK.\n"));
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return 0; /* client disconnected */
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Transmitting shutdown ACK.\n"));
+
+ msg = (struct GNUNET_MessageHeader *) buf;
+ msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK);
+ msg->size = htons (sizeof (struct GNUNET_MessageHeader));
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ GNUNET_SERVER_client_drop(client);
+ return sizeof (struct GNUNET_MessageHeader);
+}
+
/**
+ * Handler for SHUTDOWN message.
+ *
+ * @param cls closure (refers to service)
+ * @param client identification of the client
+ * @param message the actual message
+ */
+static void
+handle_shutdown (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ GNUNET_SERVER_client_keep(client);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Initiating shutdown as requested by client.\n"));
+
+ GNUNET_SERVER_notify_transmit_ready (client,
+ sizeof(struct GNUNET_MessageHeader),
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &transmit_shutdown_ack, client);
+ GNUNET_SERVER_client_persist_ (client);
+ GNUNET_SCHEDULER_shutdown (sched);
+}
+
+
+/**
* List of handlers for the messages understood by this service.
*/
static struct GNUNET_SERVER_MessageHandler handlers[] = {
{&handle_start, NULL, GNUNET_MESSAGE_TYPE_ARM_START, 0},
{&handle_stop, NULL, GNUNET_MESSAGE_TYPE_ARM_STOP, 0},
+ {&handle_shutdown, NULL, GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN,
+ sizeof (struct GNUNET_MessageHeader)},
{NULL, NULL, 0, 0}
};
Modified: gnunet/src/arm/mockup-service.c
===================================================================
--- gnunet/src/arm/mockup-service.c 2010-05-11 13:02:29 UTC (rev 11307)
+++ gnunet/src/arm/mockup-service.c 2010-05-11 13:06:16 UTC (rev 11308)
@@ -49,7 +49,7 @@
_("Transmitting shutdown ACK.\n"));
msg = (struct GNUNET_MessageHeader *) buf;
- msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN_ACK);
+ msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK);
msg->size = htons (sizeof (struct GNUNET_MessageHeader));
GNUNET_SERVER_receive_done (client, GNUNET_OK);
GNUNET_SERVER_client_drop(client);
@@ -87,7 +87,7 @@
* struct.
*/
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
- {&handle_shutdown, NULL, GNUNET_MESSAGE_TYPE_SHUTDOWN,
+ {&handle_shutdown, NULL, GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN,
sizeof (struct GNUNET_MessageHeader)},
{NULL, NULL, 0, 0}
};
Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h 2010-05-11 13:02:29 UTC (rev
11307)
+++ gnunet/src/include/gnunet_protocols.h 2010-05-11 13:06:16 UTC (rev
11308)
@@ -40,12 +40,7 @@
*/
#define GNUNET_MESSAGE_TYPE_TEST 0
-/**
- * Request service shutdown.
- */
-#define GNUNET_MESSAGE_TYPE_SHUTDOWN 1
-
/**
* Request DNS resolution.
*/
@@ -105,17 +100,15 @@
#define GNUNET_MESSAGE_TYPE_ARM_IS_UNKNOWN 12
/**
- * Acknowledge service shutting down, disconnect
- * indicates service stopped.
+ * Request ARM service shutdown.
*/
-#define GNUNET_MESSAGE_TYPE_SHUTDOWN_ACK 13
+#define GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN 13
/**
- * Deny service shutdown, disconnect indicates
- * service won't be stopped as a result of shutdown
- * message.
+ * Acknowledge service shutting down, disconnect
+ * indicates service stopped.
*/
-#define GNUNET_MESSAGE_TYPE_SHUTDOWN_REFUSE 14
+#define GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK 14
/**
* HELLO message used for communicating peer addresses.
Modified: gnunet/src/util/client.c
===================================================================
--- gnunet/src/util/client.c 2010-05-11 13:02:29 UTC (rev 11307)
+++ gnunet/src/util/client.c 2010-05-11 13:06:16 UTC (rev 11308)
@@ -624,30 +624,28 @@
else
{
GNUNET_assert(ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader));
-
switch (ntohs(msg->type))
- {
- case GNUNET_MESSAGE_TYPE_SHUTDOWN_ACK:
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
- "Received confirmation for service shutdown.\n");
- shutdown_ctx->confirmed = GNUNET_YES;
- GNUNET_CLIENT_receive (shutdown_ctx->sock,
- &service_shutdown_handler,
- shutdown_ctx,
- GNUNET_TIME_UNIT_FOREVER_REL);
- break;
- case GNUNET_MESSAGE_TYPE_SHUTDOWN_REFUSE:
- default: /* Fall through */
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
- "Service shutdown refused!\n");
- if (shutdown_ctx->cont != NULL)
- shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES);
-
- GNUNET_SCHEDULER_cancel(shutdown_ctx->sched,
shutdown_ctx->cancel_task);
- GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
- GNUNET_free(shutdown_ctx);
- break;
- }
+ {
+ case GNUNET_MESSAGE_TYPE_SHUTDOWN_ACK:
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ "Received confirmation for service shutdown.\n");
+ shutdown_ctx->confirmed = GNUNET_YES;
+ GNUNET_CLIENT_receive (shutdown_ctx->sock,
+ &service_shutdown_handler,
+ shutdown_ctx,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+ break;
+ default: /* Fall through */
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ "Service shutdown refused!\n");
+ if (shutdown_ctx->cont != NULL)
+ shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES);
+
+ GNUNET_SCHEDULER_cancel(shutdown_ctx->sched,
shutdown_ctx->cancel_task);
+ GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
+ GNUNET_free(shutdown_ctx);
+ break;
+ }
}
}
@@ -701,7 +699,7 @@
&service_shutdown_cancel,
shutdown_ctx);
msg = (struct GNUNET_MessageHeader *) buf;
- msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN);
+ msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN);
msg->size = htons (sizeof (struct GNUNET_MessageHeader));
return sizeof (struct GNUNET_MessageHeader);
}
Modified: gnunet/src/util/service.c
===================================================================
--- gnunet/src/util/service.c 2010-05-11 13:02:29 UTC (rev 11307)
+++ gnunet/src/util/service.c 2010-05-11 13:06:16 UTC (rev 11308)
@@ -570,91 +570,7 @@
}
-static size_t
-transmit_shutdown_deny (void *cls, size_t size, void *buf)
-{
- struct GNUNET_SERVER_Client *client = cls;
- struct GNUNET_MessageHeader *msg;
-
- if (size < sizeof (struct GNUNET_MessageHeader))
- {
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return 0; /* client disconnected */
- }
- msg = (struct GNUNET_MessageHeader *) buf;
- msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN_REFUSE);
- msg->size = htons (sizeof (struct GNUNET_MessageHeader));
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- GNUNET_SERVER_client_drop(client);
- return sizeof (struct GNUNET_MessageHeader);
-}
-
-static size_t
-transmit_shutdown_ack (void *cls, size_t size, void *buf)
-{
- struct GNUNET_SERVER_Client *client = cls;
- struct GNUNET_MessageHeader *msg;
-
- if (size < sizeof (struct GNUNET_MessageHeader))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Failed to transmit shutdown ACK.\n"));
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return 0; /* client disconnected */
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Transmitting shutdown ACK.\n"));
-
- msg = (struct GNUNET_MessageHeader *) buf;
- msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN_ACK);
- msg->size = htons (sizeof (struct GNUNET_MessageHeader));
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- GNUNET_SERVER_client_drop(client);
- return sizeof (struct GNUNET_MessageHeader);
-}
-
/**
- * Handler for SHUTDOWN message.
- *
- * @param cls closure (refers to service)
- * @param client identification of the client
- * @param message the actual message
- */
-static void
-handle_shutdown (void *cls,
- struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
-{
- struct GNUNET_SERVICE_Context *service = cls;
-
- GNUNET_SERVER_client_keep(client);
- if (!service->allow_shutdown)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _
- ("Received shutdown request, but configured to ignore!\n"));
- GNUNET_SERVER_notify_transmit_ready (client,
- sizeof(struct GNUNET_MessageHeader),
- GNUNET_TIME_UNIT_FOREVER_REL,
- &transmit_shutdown_deny, client);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Initiating shutdown as requested by client.\n"));
-
- GNUNET_SERVER_notify_transmit_ready (client,
- sizeof(struct GNUNET_MessageHeader),
- GNUNET_TIME_UNIT_FOREVER_REL,
- &transmit_shutdown_ack, client);
-
- GNUNET_assert (service->sched != NULL);
- GNUNET_SERVER_client_persist_ (client);
- GNUNET_SCHEDULER_shutdown (service->sched);
-}
-
-
-/**
* Default handlers for all services. Will be copied and the
* "callback_cls" fields will be replaced with the specific service
* struct.
@@ -662,8 +578,6 @@
static const struct GNUNET_SERVER_MessageHandler defhandlers[] = {
{&handle_test, NULL, GNUNET_MESSAGE_TYPE_TEST,
sizeof (struct GNUNET_MessageHeader)},
- {&handle_shutdown, NULL, GNUNET_MESSAGE_TYPE_SHUTDOWN,
- sizeof (struct GNUNET_MessageHeader)},
{NULL, NULL, 0, 0}
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11308 - in gnunet/src: arm include util,
gnunet <=