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.c91
1 files changed, 38 insertions, 53 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 1249fe003..c6259c273 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -163,7 +163,7 @@ struct ServiceList
163 * to start it)? #GNUNET_NO if the service is started only upon 'accept' on a 163 * to start it)? #GNUNET_NO if the service is started only upon 'accept' on a
164 * listen socket or possibly explicitly by a client changing the value. 164 * listen socket or possibly explicitly by a client changing the value.
165 */ 165 */
166 int is_default; 166 int force_start;
167 167
168 /** 168 /**
169 * Should we use pipes to signal this process? (YES for Java binaries and if we 169 * Should we use pipes to signal this process? (YES for Java binaries and if we
@@ -669,7 +669,7 @@ create_listen_socket (struct sockaddr *sa, socklen_t addr_len,
669#ifdef LINUX 669#ifdef LINUX
670 /* Permission settings are not required when abstract sockets are used */ 670 /* Permission settings are not required when abstract sockets are used */
671 && ('\0' != ((const struct sockaddr_un *)sa)->sun_path[0]) 671 && ('\0' != ((const struct sockaddr_un *)sa)->sun_path[0])
672#endif 672#endif
673 ) 673 )
674 { 674 {
675 match_uid = 675 match_uid =
@@ -735,7 +735,8 @@ free_service (struct ServiceList *sl)
735 * #GNUNET_SYSERR to close it (signal serious error) 735 * #GNUNET_SYSERR to close it (signal serious error)
736 */ 736 */
737static void 737static void
738handle_start (void *cls, struct GNUNET_SERVER_Client *client, 738handle_start (void *cls,
739 struct GNUNET_SERVER_Client *client,
739 const struct GNUNET_MessageHeader *message) 740 const struct GNUNET_MessageHeader *message)
740{ 741{
741 const char *servicename; 742 const char *servicename;
@@ -770,7 +771,7 @@ handle_start (void *cls, struct GNUNET_SERVER_Client *client,
770 GNUNET_SERVER_receive_done (client, GNUNET_OK); 771 GNUNET_SERVER_receive_done (client, GNUNET_OK);
771 return; 772 return;
772 } 773 }
773 sl->is_default = GNUNET_YES; 774 sl->force_start = GNUNET_YES;
774 if (NULL != sl->proc) 775 if (NULL != sl->proc)
775 { 776 {
776 signal_result (client, servicename, request_id, 777 signal_result (client, servicename, request_id,
@@ -790,9 +791,11 @@ handle_start (void *cls, struct GNUNET_SERVER_Client *client,
790 * @param tc task context 791 * @param tc task context
791 */ 792 */
792static void 793static void
793trigger_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 794trigger_shutdown (void *cls,
795 const struct GNUNET_SCHEDULER_TaskContext *tc)
794{ 796{
795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Triggering shutdown\n"); 797 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
798 "Triggering shutdown\n");
796 GNUNET_SCHEDULER_shutdown (); 799 GNUNET_SCHEDULER_shutdown ();
797} 800}
798 801
@@ -807,7 +810,8 @@ trigger_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
807 * #GNUNET_SYSERR to close it (signal serious error) 810 * #GNUNET_SYSERR to close it (signal serious error)
808 */ 811 */
809static void 812static void
810handle_stop (void *cls, struct GNUNET_SERVER_Client *client, 813handle_stop (void *cls,
814 struct GNUNET_SERVER_Client *client,
811 const struct GNUNET_MessageHeader *message) 815 const struct GNUNET_MessageHeader *message)
812{ 816{
813 struct ServiceList *sl; 817 struct ServiceList *sl;
@@ -846,7 +850,7 @@ handle_stop (void *cls, struct GNUNET_SERVER_Client *client,
846 GNUNET_SERVER_receive_done (client, GNUNET_OK); 850 GNUNET_SERVER_receive_done (client, GNUNET_OK);
847 return; 851 return;
848 } 852 }
849 sl->is_default = GNUNET_NO; 853 sl->force_start = GNUNET_NO;
850 if (GNUNET_YES == in_shutdown) 854 if (GNUNET_YES == in_shutdown)
851 { 855 {
852 /* shutdown in progress */ 856 /* shutdown in progress */
@@ -1002,7 +1006,8 @@ list_count (struct ServiceList *running_head)
1002 * @param tc context 1006 * @param tc context
1003 */ 1007 */
1004static void 1008static void
1005shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1009shutdown_task (void *cls,
1010 const struct GNUNET_SCHEDULER_TaskContext *tc)
1006{ 1011{
1007 struct ServiceList *pos; 1012 struct ServiceList *pos;
1008 struct ServiceList *nxt; 1013 struct ServiceList *nxt;
@@ -1093,11 +1098,12 @@ delayed_restart_task (void *cls,
1093 if (0 == GNUNET_TIME_absolute_get_remaining (sl->restart_at).rel_value_us) 1098 if (0 == GNUNET_TIME_absolute_get_remaining (sl->restart_at).rel_value_us)
1094 { 1099 {
1095 /* restart is now allowed */ 1100 /* restart is now allowed */
1096 if (sl->is_default) 1101 if (sl->force_start)
1097 { 1102 {
1098 /* process should run by default, start immediately */ 1103 /* process should run by default, start immediately */
1099 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1104 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1100 _("Restarting service `%s'.\n"), sl->name); 1105 _("Restarting service `%s'.\n"),
1106 sl->name);
1101 start_process (sl, NULL, 0); 1107 start_process (sl, NULL, 0);
1102 } 1108 }
1103 else 1109 else
@@ -1377,9 +1383,18 @@ setup_service (void *cls, const char *section)
1377#endif 1383#endif
1378 GNUNET_CONTAINER_DLL_insert (running_head, running_tail, sl); 1384 GNUNET_CONTAINER_DLL_insert (running_head, running_tail, sl);
1379 1385
1380 if (GNUNET_YES != 1386 if (GNUNET_YES ==
1381 GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "AUTOSTART")) 1387 GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "FORCESTART"))
1388 {
1389 sl->force_start = GNUNET_YES;
1382 return; 1390 return;
1391 }
1392 else
1393 {
1394 if (GNUNET_YES !=
1395 GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "AUTOSTART"))
1396 return;
1397 }
1383 if (0 >= (ret = GNUNET_SERVICE_get_server_addresses (section, cfg, 1398 if (0 >= (ret = GNUNET_SERVICE_get_server_addresses (section, cfg,
1384 &addrs, &addr_lens))) 1399 &addrs, &addr_lens)))
1385 return; 1400 return;
@@ -1451,8 +1466,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *serv,
1451 sizeof (struct GNUNET_ARM_Message)}, 1466 sizeof (struct GNUNET_ARM_Message)},
1452 {NULL, NULL, 0, 0} 1467 {NULL, NULL, 0, 0}
1453 }; 1468 };
1454 char *defaultservices;
1455 const char *pos;
1456 struct ServiceList *sl; 1469 struct ServiceList *sl;
1457 1470
1458 cfg = c; 1471 cfg = c;
@@ -1490,45 +1503,17 @@ run (void *cls, struct GNUNET_SERVER_Handle *serv,
1490 GNUNET_CONFIGURATION_iterate_sections (cfg, &setup_service, NULL); 1503 GNUNET_CONFIGURATION_iterate_sections (cfg, &setup_service, NULL);
1491 1504
1492 /* start default services... */ 1505 /* start default services... */
1493 if (GNUNET_OK == 1506 for (sl = running_head; NULL != sl; sl = sl->next)
1494 GNUNET_CONFIGURATION_get_value_string (cfg, 1507 if (GNUNET_YES == sl->force_start)
1495 "ARM", 1508 start_process (sl, NULL, 0);
1496 "DEFAULTSERVICES", 1509 notifier
1497 &defaultservices)) 1510 = GNUNET_SERVER_notification_context_create (server,
1498 { 1511 MAX_NOTIFY_QUEUE);
1499 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1512 GNUNET_SERVER_connect_notify (server,
1500 _("Starting default services `%s'\n"), 1513 &handle_client_connecting, NULL);
1501 defaultservices);
1502 if (0 < strlen (defaultservices))
1503 {
1504 for (pos = strtok (defaultservices, " "); NULL != pos;
1505 pos = strtok (NULL, " "))
1506 {
1507 sl = find_service (pos);
1508 if (NULL == sl)
1509 {
1510 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1511 _("Default service `%s' not configured correctly!\n"),
1512 pos);
1513 continue;
1514 }
1515 sl->is_default = GNUNET_YES;
1516 start_process (sl, NULL, 0);
1517 }
1518 }
1519 GNUNET_free (defaultservices);
1520 }
1521 else
1522 {
1523 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1524 _("No default services configured, GNUnet will not really start right now.\n"));
1525 }
1526
1527 notifier =
1528 GNUNET_SERVER_notification_context_create (server, MAX_NOTIFY_QUEUE);
1529 GNUNET_SERVER_connect_notify (server, handle_client_connecting, NULL);
1530 /* process client requests */ 1514 /* process client requests */
1531 GNUNET_SERVER_add_handlers (server, handlers); 1515 GNUNET_SERVER_add_handlers (server,
1516 handlers);
1532} 1517}
1533 1518
1534 1519