aboutsummaryrefslogtreecommitdiff
path: root/src/arm
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-11 13:06:16 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-11 13:06:16 +0000
commitdd5612fda0a14a944ff5f0c99044449adca55605 (patch)
treef6740b863fdc886606658e068f80b1cdac886ef8 /src/arm
parente6a918a6b4e22ba7bf61ba418923837481864a8c (diff)
downloadgnunet-dd5612fda0a14a944ff5f0c99044449adca55605.tar.gz
gnunet-dd5612fda0a14a944ff5f0c99044449adca55605.zip
arm-specific
Diffstat (limited to 'src/arm')
-rw-r--r--src/arm/gnunet-service-arm.c52
-rw-r--r--src/arm/mockup-service.c4
2 files changed, 54 insertions, 2 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 71a2aa446..aa4f89bdb 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -966,12 +966,64 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
966} 966}
967 967
968 968
969static size_t
970transmit_shutdown_ack (void *cls, size_t size, void *buf)
971{
972 struct GNUNET_SERVER_Client *client = cls;
973 struct GNUNET_MessageHeader *msg;
974
975 if (size < sizeof (struct GNUNET_MessageHeader))
976 {
977 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
978 _("Failed to transmit shutdown ACK.\n"));
979 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
980 return 0; /* client disconnected */
981 }
982
983 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
984 _("Transmitting shutdown ACK.\n"));
985
986 msg = (struct GNUNET_MessageHeader *) buf;
987 msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK);
988 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
989 GNUNET_SERVER_receive_done (client, GNUNET_OK);
990 GNUNET_SERVER_client_drop(client);
991 return sizeof (struct GNUNET_MessageHeader);
992}
993
994/**
995 * Handler for SHUTDOWN message.
996 *
997 * @param cls closure (refers to service)
998 * @param client identification of the client
999 * @param message the actual message
1000 */
1001static void
1002handle_shutdown (void *cls,
1003 struct GNUNET_SERVER_Client *client,
1004 const struct GNUNET_MessageHeader *message)
1005{
1006 GNUNET_SERVER_client_keep(client);
1007 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1008 _("Initiating shutdown as requested by client.\n"));
1009
1010 GNUNET_SERVER_notify_transmit_ready (client,
1011 sizeof(struct GNUNET_MessageHeader),
1012 GNUNET_TIME_UNIT_FOREVER_REL,
1013 &transmit_shutdown_ack, client);
1014 GNUNET_SERVER_client_persist_ (client);
1015 GNUNET_SCHEDULER_shutdown (sched);
1016}
1017
1018
969/** 1019/**
970 * List of handlers for the messages understood by this service. 1020 * List of handlers for the messages understood by this service.
971 */ 1021 */
972static struct GNUNET_SERVER_MessageHandler handlers[] = { 1022static struct GNUNET_SERVER_MessageHandler handlers[] = {
973 {&handle_start, NULL, GNUNET_MESSAGE_TYPE_ARM_START, 0}, 1023 {&handle_start, NULL, GNUNET_MESSAGE_TYPE_ARM_START, 0},
974 {&handle_stop, NULL, GNUNET_MESSAGE_TYPE_ARM_STOP, 0}, 1024 {&handle_stop, NULL, GNUNET_MESSAGE_TYPE_ARM_STOP, 0},
1025 {&handle_shutdown, NULL, GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN,
1026 sizeof (struct GNUNET_MessageHeader)},
975 {NULL, NULL, 0, 0} 1027 {NULL, NULL, 0, 0}
976}; 1028};
977 1029
diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c
index dd0f5b122..8a4940630 100644
--- a/src/arm/mockup-service.c
+++ b/src/arm/mockup-service.c
@@ -49,7 +49,7 @@ transmit_shutdown_ack (void *cls, size_t size, void *buf)
49 _("Transmitting shutdown ACK.\n")); 49 _("Transmitting shutdown ACK.\n"));
50 50
51 msg = (struct GNUNET_MessageHeader *) buf; 51 msg = (struct GNUNET_MessageHeader *) buf;
52 msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN_ACK); 52 msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK);
53 msg->size = htons (sizeof (struct GNUNET_MessageHeader)); 53 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
54 GNUNET_SERVER_receive_done (client, GNUNET_OK); 54 GNUNET_SERVER_receive_done (client, GNUNET_OK);
55 GNUNET_SERVER_client_drop(client); 55 GNUNET_SERVER_client_drop(client);
@@ -87,7 +87,7 @@ handle_shutdown (void *cls,
87 * struct. 87 * struct.
88 */ 88 */
89static const struct GNUNET_SERVER_MessageHandler handlers[] = { 89static const struct GNUNET_SERVER_MessageHandler handlers[] = {
90 {&handle_shutdown, NULL, GNUNET_MESSAGE_TYPE_SHUTDOWN, 90 {&handle_shutdown, NULL, GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN,
91 sizeof (struct GNUNET_MessageHeader)}, 91 sizeof (struct GNUNET_MessageHeader)},
92 {NULL, NULL, 0, 0} 92 {NULL, NULL, 0, 0}
93}; 93};