[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26649 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26649 - gnunet/src/testbed |
Date: |
Thu, 28 Mar 2013 17:01:51 +0100 |
Author: harsha
Date: 2013-03-28 17:01:51 +0100 (Thu, 28 Mar 2013)
New Revision: 26649
Modified:
gnunet/src/testbed/test_testbed_api_test.c
gnunet/src/testbed/testbed_api.c
gnunet/src/testbed/testbed_api_testbed.c
Log:
- fix crashes in testbed_api_testbed upon interrupts
Modified: gnunet/src/testbed/test_testbed_api_test.c
===================================================================
--- gnunet/src/testbed/test_testbed_api_test.c 2013-03-28 15:59:34 UTC (rev
26648)
+++ gnunet/src/testbed/test_testbed_api_test.c 2013-03-28 16:01:51 UTC (rev
26649)
@@ -112,7 +112,7 @@
abort_task = GNUNET_SCHEDULER_NO_TASK;
if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
GNUNET_SCHEDULER_cancel (shutdown_task);
- shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL);
+ do_shutdown (cls, tc);
}
Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c 2013-03-28 15:59:34 UTC (rev 26648)
+++ gnunet/src/testbed/testbed_api.c 2013-03-28 16:01:51 UTC (rev 26649)
@@ -2073,10 +2073,16 @@
{
struct OperationContext *opc = cls;
- if (OPC_STATE_FINISHED != opc->state)
+ switch (opc->state)
{
+ case OPC_STATE_STARTED:
+ GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
+ /* no break; continue */
+ case OPC_STATE_INIT:
GNUNET_free (opc->data);
- GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
+ break;
+ case OPC_STATE_FINISHED:
+ break;
}
GNUNET_free (opc);
}
Modified: gnunet/src/testbed/testbed_api_testbed.c
===================================================================
--- gnunet/src/testbed/testbed_api_testbed.c 2013-03-28 15:59:34 UTC (rev
26648)
+++ gnunet/src/testbed/testbed_api_testbed.c 2013-03-28 16:01:51 UTC (rev
26649)
@@ -239,6 +239,11 @@
GNUNET_SCHEDULER_TaskIdentifier timeout_task;
/**
+ * Task run upon shutdown interrupts
+ */
+ GNUNET_SCHEDULER_TaskIdentifier interrupt_task;
+
+ /**
* The event mask for the controller
*/
uint64_t event_mask;
@@ -327,24 +332,12 @@
GNUNET_free (rc);
}
-
-/**
- * Stops the testbed run and releases any used resources
- *
- * @param cls the tesbed run handle
- * @param tc the task context from scheduler
- */
static void
-shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+cleanup (struct RunContext *rc)
{
- struct RunContext *rc = cls;
struct DLLOperation *dll_op;
unsigned int nhost;
- GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != rc->shutdown_run_task);
- rc->shutdown_run_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_assert (GNUNET_NO == rc->shutdown);
- rc->shutdown = GNUNET_YES;
if (NULL != rc->hc_handles)
{
for (nhost = 0; nhost < rc->num_hosts; nhost++)
@@ -364,34 +357,55 @@
GNUNET_SCHEDULER_cancel (rc->timeout_task);
rc->timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
+ if (GNUNET_SCHEDULER_NO_TASK != rc->interrupt_task)
+ {
+ GNUNET_SCHEDULER_cancel (rc->interrupt_task);
+ rc->interrupt_task = GNUNET_SCHEDULER_NO_TASK;
+ }
if (NULL != rc->reg_handle)
{
GNUNET_TESTBED_cancel_registration (rc->reg_handle);
rc->reg_handle = NULL;
}
+ if (NULL != rc->topology_operation)
+ {
+ GNUNET_TESTBED_operation_done (rc->topology_operation);
+ rc->topology_operation = NULL;
+ }
/* cancel any exiting operations */
- if (NULL != rc->dll_op_head)
+ while (NULL != (dll_op = rc->dll_op_head))
{
- while (NULL != (dll_op = rc->dll_op_head))
- {
- GNUNET_TESTBED_operation_done (dll_op->op);
- GNUNET_CONTAINER_DLL_remove (rc->dll_op_head, rc->dll_op_tail, dll_op);
- GNUNET_free (dll_op);
- }
+ GNUNET_TESTBED_operation_done (dll_op->op);
+ GNUNET_CONTAINER_DLL_remove (rc->dll_op_head, rc->dll_op_tail, dll_op);
+ GNUNET_free (dll_op);
}
+}
+
+
+/**
+ * Stops the testbed run and releases any used resources
+ *
+ * @param cls the tesbed run handle
+ * @param tc the task context from scheduler
+ */
+static void
+shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct RunContext *rc = cls;
+ struct DLLOperation *dll_op;
+
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != rc->shutdown_run_task);
+ rc->shutdown_run_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_assert (GNUNET_NO == rc->shutdown);
+ rc->shutdown = GNUNET_YES;
+ cleanup (rc);
if (NULL != rc->c)
{
if (NULL != rc->peers)
{
- if (NULL != rc->topology_operation)
- {
- GNUNET_TESTBED_operation_done (rc->topology_operation);
- rc->topology_operation = NULL;
- }
- if (RC_INIT == rc->state)
- rc->state = RC_READY; /* Even though we haven't called the master
callback */
dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
dll_op->op = GNUNET_TESTBED_shutdown_peers (rc->c, dll_op, NULL, NULL);
+ GNUNET_assert (NULL != dll_op->op);
DEBUG ("Shutting down peers\n");
rc->pstart_time = GNUNET_TIME_absolute_get ();
GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail,
@@ -422,6 +436,16 @@
}
+static void
+interrupt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct RunContext *rc = cls;
+
+ rc->interrupt_task = GNUNET_SCHEDULER_NO_TASK;
+ shutdown_now (rc);
+}
+
+
/**
* Function to return the string representation of the duration between current
* time and `pstart_time' in `RunContext'
@@ -458,6 +482,7 @@
{
dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
dll_op->op = GNUNET_TESTBED_peer_start (NULL, rc->peers[peer], NULL, NULL);
+ GNUNET_assert (NULL != dll_op->op);
dll_op->cls = rc->peers[peer];
GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail,
dll_op);
}
@@ -568,7 +593,8 @@
(0 ==
rc->num_hosts) ? rc->h : rc->hosts[peer %
rc->num_hosts],
- rc->cfg, peer_create_cb, dll_op);
+ rc->cfg, peer_create_cb, dll_op);
+ GNUNET_assert (NULL != dll_op->op);
GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail,
dll_op);
}
}
@@ -778,6 +804,7 @@
dll_op->op =
GNUNET_TESTBED_controller_link (dll_op, rc->c, rc->hosts[slave],
rc->h, rc->cfg, GNUNET_YES);
+ GNUNET_assert (NULL != dll_op->op);
GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail,
dll_op);
}
@@ -812,12 +839,19 @@
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Controller crash detected. Shutting down.\n"));
rc->cproc = NULL;
+ cleanup (rc);
if (NULL != rc->peers)
{
GNUNET_free (rc->peers);
rc->peers = NULL;
}
- shutdown_now (rc);
+ if (GNUNET_YES == rc->shutdown)
+ {
+ rc->state = RC_PEERS_SHUTDOWN;
+ GNUNET_SCHEDULER_add_now (&cleanup_task, rc);
+ }
+ else
+ shutdown_now (rc);
return;
}
GNUNET_CONFIGURATION_destroy (rc->cfg);
@@ -1140,8 +1174,8 @@
}
rc->timeout_task =
GNUNET_SCHEDULER_add_delayed (timeout, &timeout_task, rc);
- rc->shutdown_run_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
&shutdown_run,
+ rc->interrupt_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &interrupt,
rc);
return;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26649 - gnunet/src/testbed,
gnunet <=