[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9522 - gnunet/src/arm
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9522 - gnunet/src/arm |
Date: |
Sun, 15 Nov 2009 11:12:20 -0700 |
Author: grothoff
Date: 2009-11-15 11:12:19 -0700 (Sun, 15 Nov 2009)
New Revision: 9522
Modified:
gnunet/src/arm/arm_api.c
gnunet/src/arm/gnunet-service-arm.c
Log:
cleaner handling of clients and service processes, ignore shutdown
Modified: gnunet/src/arm/arm_api.c
===================================================================
--- gnunet/src/arm/arm_api.c 2009-11-15 18:01:10 UTC (rev 9521)
+++ gnunet/src/arm/arm_api.c 2009-11-15 18:12:19 UTC (rev 9522)
@@ -265,7 +265,7 @@
}
#if DEBUG_ARM
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received response from ARM for service `%s': %u\n",
+ "Received response from ARM for service `%s': %u\n",
(const char*) &sc[1],
ntohs(msg->type));
#endif
@@ -379,7 +379,7 @@
size_t slen;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Asked to starting service `%s' within %llu ms\n"),
service_name,
+ _("Asked to start service `%s' within %llu ms\n"), service_name,
(unsigned long long) timeout.value);
if (0 == strcasecmp ("arm", service_name))
{
Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2009-11-15 18:01:10 UTC (rev 9521)
+++ gnunet/src/arm/gnunet-service-arm.c 2009-11-15 18:12:19 UTC (rev 9522)
@@ -194,7 +194,11 @@
struct GNUNET_MessageHeader *msg;
if (buf == NULL)
- return 0; /* error, not much we can do */
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Could not send status result to client\n"));
+ return 0; /* error, not much we can do */
+ }
GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
msg = buf;
msg->size = htons (sizeof (struct GNUNET_MessageHeader));
@@ -221,7 +225,11 @@
uint16_t *res;
if (NULL == client)
- return;
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Not sending status result to client: no client known\n"));
+ return;
+ }
#if DEBUG_ARM
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Telling client that service `%s' is now %s\n",
@@ -493,25 +501,17 @@
const char *servicename)
{
struct ServiceList *pos;
- struct GNUNET_CLIENT_Connection *sc;
- unsigned long long port;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Preparing to stop `%s'\n"), servicename);
pos = find_name (servicename);
- if ( (pos != NULL) &&
- ( (pos->kill_continuation != NULL) ||
- (GNUNET_YES == in_shutdown) ) )
+ if (pos == NULL)
{
- /* killing already in progress */
-#if DEBUG_ARM
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Service `%s' is already down\n", servicename);
-#endif
- signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
+ signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UNKNOWN);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- if ((pos != NULL) && (pos->rc > 1))
+ if (pos->rc > 1)
{
/* RC>1, just decrement RC */
pos->rc--;
@@ -527,48 +527,47 @@
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- if (pos != NULL)
+ if (pos->rc == 1)
+ pos->rc--; /* decrement RC to zero */
+ if (pos->kill_continuation != NULL)
{
+ /* killing already in progress */
#if DEBUG_ARM
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending kill signal to service `%s', waiting for process to
die.\n",
- servicename);
+ "Service `%s' is already down\n", servicename);
#endif
- if (0 != PLIBC_KILL (pos->pid, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- pos->next = running;
- running = pos;
- pos->kill_continuation = &free_and_signal;
- pos->kill_continuation_cls = client;
- GNUNET_SERVER_client_keep (client);
- GNUNET_SCHEDULER_add_delayed (sched,
- MAINT_FAST_FREQUENCY, &maint, "non-null");
+ signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
}
- else
+
+ if (GNUNET_YES == in_shutdown)
{
- if (GNUNET_YES == in_shutdown)
- return;
#if DEBUG_ARM
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending termination request to service `%s'.\n",
+ "Termination request already sent to `%s' (since ARM is in
shutdown).\n",
servicename);
#endif
- if ( (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number (cfg,
- servicename,
- "PORT",
- &port)) &&
- (NULL != (sc = GNUNET_CLIENT_connect (sched, servicename, cfg))) )
- {
- GNUNET_CLIENT_service_shutdown (sc);
- signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
- }
- else
- {
- signal_result (client, servicename,
GNUNET_MESSAGE_TYPE_ARM_IS_UNKNOWN);
- }
+ signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
}
+
+
+#if DEBUG_ARM
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending kill signal to service `%s', waiting for process to
die.\n",
+ servicename);
+#endif
+ if (0 != PLIBC_KILL (pos->pid, SIGTERM))
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ pos->next = running;
+ running = pos;
+ pos->kill_continuation = &free_and_signal;
+ pos->kill_continuation_cls = client;
+ GNUNET_SERVER_client_keep (client);
+ GNUNET_SCHEDULER_add_delayed (sched,
+ MAINT_FAST_FREQUENCY, &maint, "non-null");
}
@@ -807,6 +806,7 @@
char *defaultservices;
char *pos;
+ GNUNET_SERVER_ignore_shutdown (serv, GNUNET_YES);
GNUNET_assert (serv != NULL);
cfg = c;
sched = s;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9522 - gnunet/src/arm,
gnunet <=