aboutsummaryrefslogtreecommitdiff
path: root/src/arm
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-09 11:39:53 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-09 11:39:53 +0000
commite7674a12b370168daa102ed69cb24e96b8ed251b (patch)
tree0a02111371e36b7677226a930aa45eda05824ffd /src/arm
parent48b2340e57c4e3d460818effc0510f1a0d576b4e (diff)
downloadgnunet-e7674a12b370168daa102ed69cb24e96b8ed251b.tar.gz
gnunet-e7674a12b370168daa102ed69cb24e96b8ed251b.zip
adding code to measure and report shutdown time for services to gnunet-service-arm at INFO level logging
Diffstat (limited to 'src/arm')
-rw-r--r--src/arm/gnunet-service-arm.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 45927f12d..091d5ae54 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -146,6 +146,12 @@ struct ServiceList
146 struct GNUNET_TIME_Absolute restart_at; 146 struct GNUNET_TIME_Absolute restart_at;
147 147
148 /** 148 /**
149 * Time we asked the service to shut down (used to calculate time it took
150 * the service to terminate).
151 */
152 struct GNUNET_TIME_Absolute killed_at;
153
154 /**
149 * Is this service to be started by default (or did a client tell us explicitly 155 * Is this service to be started by default (or did a client tell us explicitly
150 * to start it)? GNUNET_NO if the service is started only upon 'accept' on a 156 * to start it)? GNUNET_NO if the service is started only upon 'accept' on a
151 * listen socket or possibly explicitly by a client changing the value. 157 * listen socket or possibly explicitly by a client changing the value.
@@ -694,6 +700,7 @@ handle_stop (void *cls, struct GNUNET_SERVER_Client *client,
694 "Sending kill signal to service `%s', waiting for process to die.\n", 700 "Sending kill signal to service `%s', waiting for process to die.\n",
695 servicename); 701 servicename);
696#endif 702#endif
703 sl->killed_at = GNUNET_TIME_absolute_get ();
697 if (0 != GNUNET_OS_process_kill (sl->proc, SIGTERM)) 704 if (0 != GNUNET_OS_process_kill (sl->proc, SIGTERM))
698 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 705 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
699 sl->killing_client = client; 706 sl->killing_client = client;
@@ -824,6 +831,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
824 { 831 {
825 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping service `%s'\n", 832 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping service `%s'\n",
826 pos->name); 833 pos->name);
834 pos->killed_at = GNUNET_TIME_absolute_get ();
827 if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM)) 835 if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM))
828 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 836 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
829 } 837 }
@@ -955,11 +963,11 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
955 next = pos->next; 963 next = pos->next;
956 964
957 if (pos->proc == NULL) 965 if (pos->proc == NULL)
958 { 966 {
959 if (GNUNET_YES == in_shutdown) 967 if (GNUNET_YES == in_shutdown)
960 free_service (pos); 968 free_service (pos);
961 continue; 969 continue;
962 } 970 }
963 if ((GNUNET_SYSERR == 971 if ((GNUNET_SYSERR ==
964 (ret = 972 (ret =
965 GNUNET_OS_process_status (pos->proc, &statusType, &statusCode))) 973 GNUNET_OS_process_status (pos->proc, &statusType, &statusCode)))
@@ -967,20 +975,27 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
967 || (statusType == GNUNET_OS_PROCESS_RUNNING))) 975 || (statusType == GNUNET_OS_PROCESS_RUNNING)))
968 continue; 976 continue;
969 if (statusType == GNUNET_OS_PROCESS_EXITED) 977 if (statusType == GNUNET_OS_PROCESS_EXITED)
970 { 978 {
971 statstr = _( /* process termination method */ "exit"); 979 statstr = _( /* process termination method */ "exit");
972 statcode = statusCode; 980 statcode = statusCode;
973 } 981 }
974 else if (statusType == GNUNET_OS_PROCESS_SIGNALED) 982 else if (statusType == GNUNET_OS_PROCESS_SIGNALED)
975 { 983 {
976 statstr = _( /* process termination method */ "signal"); 984 statstr = _( /* process termination method */ "signal");
977 statcode = statusCode; 985 statcode = statusCode;
978 } 986 }
979 else 987 else
980 { 988 {
981 statstr = _( /* process termination method */ "unknown"); 989 statstr = _( /* process termination method */ "unknown");
982 statcode = 0; 990 statcode = 0;
983 } 991 }
992 if (0 != pos->killed_at.abs_value)
993 {
994 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
995 _("Service `%s' took %llu ms to terminate\n"),
996 pos->name,
997 GNUNET_TIME_absolute_get_duration (pos->killed_at).rel_value);
998 }
984 GNUNET_OS_process_close (pos->proc); 999 GNUNET_OS_process_close (pos->proc);
985 pos->proc = NULL; 1000 pos->proc = NULL;
986 if (NULL != pos->killing_client) 1001 if (NULL != pos->killing_client)