[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31655 - gnunet-gtk/src/main
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31655 - gnunet-gtk/src/main |
Date: |
Sat, 21 Dec 2013 22:34:58 +0100 |
Author: grothoff
Date: 2013-12-21 22:34:58 +0100 (Sat, 21 Dec 2013)
New Revision: 31655
Modified:
gnunet-gtk/src/main/gnunet-gtk.c
Log:
-use exponential backoff for restarts
Modified: gnunet-gtk/src/main/gnunet-gtk.c
===================================================================
--- gnunet-gtk/src/main/gnunet-gtk.c 2013-12-21 18:05:02 UTC (rev 31654)
+++ gnunet-gtk/src/main/gnunet-gtk.c 2013-12-21 21:34:58 UTC (rev 31655)
@@ -34,8 +34,14 @@
struct Plug
{
+ /**
+ * Kept in a DLL.
+ */
struct Plug *prev;
+ /**
+ * Kept in a DLL.
+ */
struct Plug *next;
/**
@@ -57,6 +63,17 @@
* Handle to the child process.
*/
struct GNUNET_OS_Process *proc;
+
+ /**
+ * How long do we wait on restarts?
+ */
+ struct GNUNET_TIME_Relative backoff;
+
+ /**
+ * Task to restart process after crash.
+ */
+ GNUNET_SCHEDULER_TaskIdentifier restart_task;
+
};
@@ -115,11 +132,19 @@
while (NULL != (p = p_head))
{
- (void) GNUNET_OS_process_kill (p->proc, SIGTERM);
- GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (p->proc));
- GNUNET_OS_process_destroy (p->proc);
- p->proc = NULL;
+ if (NULL != p->proc)
+ {
+ (void) GNUNET_OS_process_kill (p->proc, SIGTERM);
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_OS_process_wait (p->proc));
+ GNUNET_OS_process_destroy (p->proc);
+ p->proc = NULL;
+ }
+ if (GNUNET_SCHEDULER_NO_TASK != p->restart_task)
+ {
+ GNUNET_SCHEDULER_cancel (p->restart_task);
+ p->restart_task = GNUNET_SCHEDULER_NO_TASK;
+ }
GNUNET_CONTAINER_DLL_remove (p_head,
p_tail,
p);
@@ -173,6 +198,26 @@
/**
+ * Restart crashed plugin process.
+ *
+ * @param cls the `struct Plug` of the plugin
+ * @param tc scheduler context
+ */
+static void
+restart_process (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct Plug *p = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Restarting crashed plugin `%s'\n"),
+ p->binary);
+ p->restart_task = GNUNET_SCHEDULER_NO_TASK;
+ start_process (p);
+}
+
+
+/**
* The window got detached, restart the child.
*
* @param sock socket the plug got detached from
@@ -188,7 +233,10 @@
(void) GNUNET_OS_process_kill (p->proc, SIGTERM);
GNUNET_OS_process_destroy (p->proc);
p->proc = NULL;
- start_process (p);
+ p->backoff = GNUNET_TIME_STD_BACKOFF (p->backoff);
+ p->restart_task = GNUNET_SCHEDULER_add_delayed (p->backoff,
+ &restart_process,
+ p);
return TRUE;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31655 - gnunet-gtk/src/main,
gnunet <=