aboutsummaryrefslogtreecommitdiff
path: root/src/arm/gnunet-service-arm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arm/gnunet-service-arm.c')
-rw-r--r--src/arm/gnunet-service-arm.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 906f0adde..1196b20aa 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -259,7 +259,7 @@ write_result (void *cls, size_t size, void *buf)
259 return 0; /* error, not much we can do */ 259 return 0; /* error, not much we can do */
260 } 260 }
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
262 "Sending status response %u to client\n", 262 "Sending status response %u to client\n",
263 (unsigned int) msg->result); 263 (unsigned int) msg->result);
264 msize = msg->arm_msg.header.size; 264 msize = msg->arm_msg.header.size;
265 GNUNET_assert (size >= msize); 265 GNUNET_assert (size >= msize);
@@ -275,7 +275,7 @@ write_result (void *cls, size_t size, void *buf)
275 275
276/** 276/**
277 * Transmit the list of running services. 277 * Transmit the list of running services.
278 * 278 *
279 * @param cls pointer to `struct GNUNET_ARM_ListResultMessage` with the message 279 * @param cls pointer to `struct GNUNET_ARM_ListResultMessage` with the message
280 * @param size number of bytes available in @a buf 280 * @param size number of bytes available in @a buf
281 * @param buf where to copy the message, NULL on error 281 * @param buf where to copy the message, NULL on error
@@ -286,7 +286,7 @@ write_list_result (void *cls, size_t size, void *buf)
286{ 286{
287 struct GNUNET_ARM_ListResultMessage *msg = cls; 287 struct GNUNET_ARM_ListResultMessage *msg = cls;
288 size_t rslt_size; 288 size_t rslt_size;
289 289
290 if (buf == NULL) 290 if (buf == NULL)
291 { 291 {
292 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 292 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -294,14 +294,14 @@ write_list_result (void *cls, size_t size, void *buf)
294 GNUNET_free (msg); 294 GNUNET_free (msg);
295 return 0; /* error, not much we can do */ 295 return 0; /* error, not much we can do */
296 } 296 }
297 297
298 rslt_size = msg->arm_msg.header.size; 298 rslt_size = msg->arm_msg.header.size;
299 GNUNET_assert (size >= rslt_size); 299 GNUNET_assert (size >= rslt_size);
300 msg->arm_msg.header.size = htons (msg->arm_msg.header.size); 300 msg->arm_msg.header.size = htons (msg->arm_msg.header.size);
301 msg->arm_msg.header.type = htons (msg->arm_msg.header.type); 301 msg->arm_msg.header.type = htons (msg->arm_msg.header.type);
302 msg->arm_msg.request_id = GNUNET_htonll (msg->arm_msg.request_id); 302 msg->arm_msg.request_id = GNUNET_htonll (msg->arm_msg.request_id);
303 msg->count = htons (msg->count); 303 msg->count = htons (msg->count);
304 304
305 memcpy (buf, msg, rslt_size); 305 memcpy (buf, msg, rslt_size);
306 GNUNET_free (msg); 306 GNUNET_free (msg);
307 return rslt_size; 307 return rslt_size;
@@ -319,7 +319,7 @@ write_list_result (void *cls, size_t size, void *buf)
319 * @return NULL if it was not found 319 * @return NULL if it was not found
320 */ 320 */
321static void 321static void
322signal_result (struct GNUNET_SERVER_Client *client, 322signal_result (struct GNUNET_SERVER_Client *client,
323 const char *name, 323 const char *name,
324 uint64_t request_id, 324 uint64_t request_id,
325 enum GNUNET_ARM_Result result) 325 enum GNUNET_ARM_Result result)
@@ -335,7 +335,7 @@ signal_result (struct GNUNET_SERVER_Client *client,
335 msg->arm_msg.request_id = request_id; 335 msg->arm_msg.request_id = request_id;
336 336
337 GNUNET_SERVER_notify_transmit_ready (client, msize, 337 GNUNET_SERVER_notify_transmit_ready (client, msize,
338 GNUNET_TIME_UNIT_FOREVER_REL, 338 GNUNET_TIME_UNIT_FOREVER_REL,
339 write_result, msg); 339 write_result, msg);
340} 340}
341 341
@@ -492,7 +492,7 @@ start_process (struct ServiceList *sl, struct GNUNET_SERVER_Client *client, uint
492 if (NULL == sl->config) 492 if (NULL == sl->config)
493 sl->proc = 493 sl->proc =
494 do_start_process (sl->pipe_control, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 494 do_start_process (sl->pipe_control, GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
495 lsocks, loprefix, binary, 495 lsocks, loprefix, binary,
496 options, NULL); 496 options, NULL);
497 else 497 else
498 sl->proc = 498 sl->proc =
@@ -693,7 +693,7 @@ handle_start (void *cls, struct GNUNET_SERVER_Client *client,
693 uint64_t request_id; 693 uint64_t request_id;
694 struct GNUNET_ARM_Message *amsg; 694 struct GNUNET_ARM_Message *amsg;
695 695
696 amsg = (struct GNUNET_ARM_Message *) message; 696 amsg = (struct GNUNET_ARM_Message *) message;
697 request_id = GNUNET_ntohll (amsg->request_id); 697 request_id = GNUNET_ntohll (amsg->request_id);
698 size = ntohs (amsg->header.size); 698 size = ntohs (amsg->header.size);
699 size -= sizeof (struct GNUNET_ARM_Message); 699 size -= sizeof (struct GNUNET_ARM_Message);
@@ -762,7 +762,7 @@ handle_stop (void *cls, struct GNUNET_SERVER_Client *client,
762 uint64_t request_id; 762 uint64_t request_id;
763 struct GNUNET_ARM_Message *amsg; 763 struct GNUNET_ARM_Message *amsg;
764 764
765 amsg = (struct GNUNET_ARM_Message *) message; 765 amsg = (struct GNUNET_ARM_Message *) message;
766 request_id = GNUNET_ntohll (amsg->request_id); 766 request_id = GNUNET_ntohll (amsg->request_id);
767 size = ntohs (amsg->header.size); 767 size = ntohs (amsg->header.size);
768 size -= sizeof (struct GNUNET_ARM_Message); 768 size -= sizeof (struct GNUNET_ARM_Message);
@@ -847,10 +847,10 @@ handle_list (void *cls, struct GNUNET_SERVER_Client *client,
847 size_t total_size; 847 size_t total_size;
848 struct ServiceList *sl; 848 struct ServiceList *sl;
849 uint16_t count; 849 uint16_t count;
850 850
851 if (NULL == client) 851 if (NULL == client)
852 return; 852 return;
853 853
854 request = (struct GNUNET_ARM_Message *) message; 854 request = (struct GNUNET_ARM_Message *) message;
855 count = 0; 855 count = 0;
856 string_list_size = 0; 856 string_list_size = 0;
@@ -866,16 +866,16 @@ handle_list (void *cls, struct GNUNET_SERVER_Client *client,
866 } 866 }
867 } 867 }
868 868
869 total_size = sizeof (struct GNUNET_ARM_ListResultMessage) 869 total_size = sizeof (struct GNUNET_ARM_ListResultMessage)
870 + string_list_size; 870 + string_list_size;
871 msg = GNUNET_malloc (total_size); 871 msg = GNUNET_malloc (total_size);
872 msg->arm_msg.header.size = total_size; 872 msg->arm_msg.header.size = total_size;
873 msg->arm_msg.header.type = GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT; 873 msg->arm_msg.header.type = GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT;
874 msg->arm_msg.request_id = GNUNET_ntohll (request->request_id); 874 msg->arm_msg.request_id = GNUNET_ntohll (request->request_id);
875 msg->count = count; 875 msg->count = count;
876 876
877 char *pos = (char *)&msg[1]; 877 char *pos = (char *)&msg[1];
878 for (sl = running_head; sl != NULL; sl = sl->next) 878 for (sl = running_head; sl != NULL; sl = sl->next)
879 { 879 {
880 if (sl->proc != NULL) 880 if (sl->proc != NULL)
881 { 881 {
@@ -884,7 +884,7 @@ handle_list (void *cls, struct GNUNET_SERVER_Client *client,
884 pos += s; 884 pos += s;
885 } 885 }
886 } 886 }
887 887
888 GNUNET_SERVER_notify_transmit_ready (client, 888 GNUNET_SERVER_notify_transmit_ready (client,
889 total_size, 889 total_size,
890 GNUNET_TIME_UNIT_FOREVER_REL, 890 GNUNET_TIME_UNIT_FOREVER_REL,
@@ -926,7 +926,7 @@ list_count (struct ServiceList *running_head)
926 unsigned int res = 0; 926 unsigned int res = 0;
927 927
928 for (res = 0, i = running_head; i; i = i->next, res++) 928 for (res = 0, i = running_head; i; i = i->next, res++)
929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
930 "%s\n", 930 "%s\n",
931 i->name); 931 i->name);
932 return res; 932 return res;
@@ -946,7 +946,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
946 struct ServiceList *nxt; 946 struct ServiceList *nxt;
947 struct ServiceListeningInfo *sli; 947 struct ServiceListeningInfo *sli;
948 948
949 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 949 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
950 "First shutdown phase\n"); 950 "First shutdown phase\n");
951 if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) 951 if (GNUNET_SCHEDULER_NO_TASK != child_restart_task)
952 { 952 {
@@ -979,7 +979,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
979 nxt = pos->next; 979 nxt = pos->next;
980 if (pos->proc != NULL) 980 if (pos->proc != NULL)
981 { 981 {
982 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 982 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
983 "Stopping service `%s'\n", 983 "Stopping service `%s'\n",
984 pos->name); 984 pos->name);
985 pos->killed_at = GNUNET_TIME_absolute_get (); 985 pos->killed_at = GNUNET_TIME_absolute_get ();
@@ -996,7 +996,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
996 do_shutdown (); 996 do_shutdown ();
997 else 997 else
998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
999 "Delaying shutdown, have %u childs still running\n", 999 "Delaying shutdown, have %u childs still running\n",
1000 list_count (running_head)); 1000 list_count (running_head));
1001} 1001}
1002 1002
@@ -1063,12 +1063,12 @@ delayed_restart_task (void *cls,
1063 } 1063 }
1064 if (lowestRestartDelay.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) 1064 if (lowestRestartDelay.rel_value_us != GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
1065 { 1065 {
1066 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1066 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1067 "Will restart process in %s\n", 1067 "Will restart process in %s\n",
1068 GNUNET_STRINGS_relative_time_to_string (lowestRestartDelay, GNUNET_YES)); 1068 GNUNET_STRINGS_relative_time_to_string (lowestRestartDelay, GNUNET_YES));
1069 child_restart_task = 1069 child_restart_task =
1070 GNUNET_SCHEDULER_add_delayed_with_priority (lowestRestartDelay, 1070 GNUNET_SCHEDULER_add_delayed_with_priority (lowestRestartDelay,
1071 GNUNET_SCHEDULER_PRIORITY_IDLE, 1071 GNUNET_SCHEDULER_PRIORITY_IDLE,
1072 &delayed_restart_task, NULL); 1072 &delayed_restart_task, NULL);
1073 } 1073 }
1074} 1074}
@@ -1275,7 +1275,7 @@ setup_service (void *cls, const char *section)
1275 { 1275 {
1276 if (NULL != config) 1276 if (NULL != config)
1277 { 1277 {
1278 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, 1278 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING,
1279 section, "CONFIG", 1279 section, "CONFIG",
1280 STRERROR (errno)); 1280 STRERROR (errno));
1281 GNUNET_free (config); 1281 GNUNET_free (config);
@@ -1293,7 +1293,7 @@ setup_service (void *cls, const char *section)
1293#else 1293#else
1294 if (GNUNET_CONFIGURATION_have_value (cfg, section, "PIPECONTROL")) 1294 if (GNUNET_CONFIGURATION_have_value (cfg, section, "PIPECONTROL"))
1295 sl->pipe_control = GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "PIPECONTROL"); 1295 sl->pipe_control = GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "PIPECONTROL");
1296#endif 1296#endif
1297 GNUNET_CONTAINER_DLL_insert (running_head, running_tail, sl); 1297 GNUNET_CONTAINER_DLL_insert (running_head, running_tail, sl);
1298 if (GNUNET_YES != 1298 if (GNUNET_YES !=
1299 GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "AUTOSTART")) 1299 GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "AUTOSTART"))
@@ -1363,9 +1363,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *serv,
1363 static const struct GNUNET_SERVER_MessageHandler handlers[] = { 1363 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
1364 {&handle_start, NULL, GNUNET_MESSAGE_TYPE_ARM_START, 0}, 1364 {&handle_start, NULL, GNUNET_MESSAGE_TYPE_ARM_START, 0},
1365 {&handle_stop, NULL, GNUNET_MESSAGE_TYPE_ARM_STOP, 0}, 1365 {&handle_stop, NULL, GNUNET_MESSAGE_TYPE_ARM_STOP, 0},
1366 {&handle_monitor, NULL, GNUNET_MESSAGE_TYPE_ARM_MONITOR, 1366 {&handle_monitor, NULL, GNUNET_MESSAGE_TYPE_ARM_MONITOR,
1367 sizeof (struct GNUNET_MessageHeader)}, 1367 sizeof (struct GNUNET_MessageHeader)},
1368 {&handle_list, NULL, GNUNET_MESSAGE_TYPE_ARM_LIST, 1368 {&handle_list, NULL, GNUNET_MESSAGE_TYPE_ARM_LIST,
1369 sizeof (struct GNUNET_ARM_Message)}, 1369 sizeof (struct GNUNET_ARM_Message)},
1370 {NULL, NULL, 0, 0} 1370 {NULL, NULL, 0, 0}
1371 }; 1371 };
@@ -1456,7 +1456,7 @@ main (int argc, char *const *argv)
1456 GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); 1456 GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
1457 ret = 1457 ret =
1458 (GNUNET_OK == 1458 (GNUNET_OK ==
1459 GNUNET_SERVICE_run (argc, argv, "arm", 1459 GNUNET_SERVICE_run (argc, argv, "arm",
1460 GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN, &run, NULL)) ? 0 : 1; 1460 GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN, &run, NULL)) ? 0 : 1;
1461 GNUNET_SIGNAL_handler_uninstall (shc_chld); 1461 GNUNET_SIGNAL_handler_uninstall (shc_chld);
1462 shc_chld = NULL; 1462 shc_chld = NULL;