aboutsummaryrefslogtreecommitdiff
path: root/src/sensor
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-24 01:10:47 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-24 01:10:47 +0000
commitf1f603c7d0b3f03dca46a4f313472288eb080eb1 (patch)
tree3a29966b02dfb83e0a8a8d5c42b3116380209fb0 /src/sensor
parent53cd5b8eda2fa8db86b0907a62a39598981d008a (diff)
making GNUNET_SCHEDULER_cancel() perform in O(1) instead of O(n) to help or even fully address #3247
Diffstat (limited to 'src/sensor')
-rw-r--r--src/sensor/gnunet-sensor-profiler.c12
-rw-r--r--src/sensor/gnunet-service-sensor_monitoring.c2
-rw-r--r--src/sensor/gnunet-service-sensor_reporting.c18
-rw-r--r--src/sensor/gnunet-service-sensor_update.c8
-rw-r--r--src/sensor/perf_pow_sign.c2
-rw-r--r--src/sensor/sensor_api.c8
-rw-r--r--src/sensor/sensor_util_lib.c6
-rw-r--r--src/sensor/sensor_util_lib_crypto.c8
-rw-r--r--src/sensor/test_gnunet-service-sensor_reporting.c12
-rw-r--r--src/sensor/test_pow_sign.c2
10 files changed, 39 insertions, 39 deletions
diff --git a/src/sensor/gnunet-sensor-profiler.c b/src/sensor/gnunet-sensor-profiler.c
index 21574774d8..74b1fa8a27 100644
--- a/src/sensor/gnunet-sensor-profiler.c
+++ b/src/sensor/gnunet-sensor-profiler.c
@@ -87,7 +87,7 @@ static const char *sensor_dst_dir = "/tmp/gnunet-sensor-profiler";
/**
* Scheduled task to shutdown
*/
-static GNUNET_SCHEDULER_TaskIdentifier shutdown_task = GNUNET_SCHEDULER_NO_TASK;
+static struct GNUNET_SCHEDULER_Task * shutdown_task = NULL;
/**
* GNUnet configuration
@@ -157,7 +157,7 @@ static unsigned int sensor_names_size = 0;
/**
* Task run after any waiting period
*/
-static GNUNET_SCHEDULER_TaskIdentifier delayed_task = GNUNET_SCHEDULER_NO_TASK;
+static struct GNUNET_SCHEDULER_Task * delayed_task = NULL;
/**
@@ -180,10 +180,10 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
int i;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down.\n");
- if (GNUNET_SCHEDULER_NO_TASK != delayed_task)
+ if (NULL != delayed_task)
{
GNUNET_SCHEDULER_cancel (delayed_task);
- delayed_task = GNUNET_SCHEDULER_NO_TASK;
+ delayed_task = NULL;
}
for (i = 0; i < num_peers; i++)
{
@@ -536,7 +536,7 @@ simulate_anomalies (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
uint32_t an_peer;
struct GNUNET_TIME_Relative shutdown_delay;
- delayed_task = GNUNET_SCHEDULER_NO_TASK;
+ delayed_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Training period over, simulating anomalies now.\n");
GNUNET_assert (anomalous_peers <= num_peers);
@@ -572,7 +572,7 @@ peers_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
unsigned long long int training_points;
struct GNUNET_TIME_Relative training_period;
- delayed_task = GNUNET_SCHEDULER_NO_TASK;
+ delayed_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers are ready.\n");
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_number (cfg,
diff --git a/src/sensor/gnunet-service-sensor_monitoring.c b/src/sensor/gnunet-service-sensor_monitoring.c
index 4f1f9472ad..f473c3a75b 100644
--- a/src/sensor/gnunet-service-sensor_monitoring.c
+++ b/src/sensor/gnunet-service-sensor_monitoring.c
@@ -410,7 +410,7 @@ schedule_sensor (void *cls, const struct GNUNET_HashCode *key, void *value)
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling sensor `%s' to run after %" PRIu64 " microseconds\n",
sensorinfo->name, sensorinfo->interval.rel_value_us);
- if (GNUNET_SCHEDULER_NO_TASK != sensorinfo->execution_task)
+ if (NULL != sensorinfo->execution_task)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Sensor `%s' execution task already set, this should not happen\n"),
diff --git a/src/sensor/gnunet-service-sensor_reporting.c b/src/sensor/gnunet-service-sensor_reporting.c
index 8d69836a01..d08d67449f 100644
--- a/src/sensor/gnunet-service-sensor_reporting.c
+++ b/src/sensor/gnunet-service-sensor_reporting.c
@@ -162,9 +162,9 @@ struct ValueInfo
struct GNUNET_PEERSTORE_WatchContext *wc;
/**
- * Collection point reporting task (or #GNUNET_SCHEDULER_NO_TASK)
+ * Collection point reporting task (or #NULL)
*/
- GNUNET_SCHEDULER_TaskIdentifier reporting_task;
+ struct GNUNET_SCHEDULER_Task * reporting_task;
};
@@ -237,7 +237,7 @@ struct CadetPeer
/**
* Task used to try reconnection to collection point after failure
*/
- GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
+ struct GNUNET_SCHEDULER_Task * reconnect_task;
/**
* Are we currently destroying the channel and its context?
@@ -400,10 +400,10 @@ destroy_value_info (struct ValueInfo *vi)
GNUNET_PEERSTORE_watch_cancel (vi->wc);
vi->wc = NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != vi->reporting_task)
+ if (NULL != vi->reporting_task)
{
GNUNET_SCHEDULER_cancel (vi->reporting_task);
- vi->reporting_task = GNUNET_SCHEDULER_NO_TASK;
+ vi->reporting_task = NULL;
}
if (NULL != vi->last_value)
{
@@ -463,10 +463,10 @@ static void
destroy_cadet_peer (struct CadetPeer *cadetp)
{
cadetp->destroying = GNUNET_YES;
- if (GNUNET_SCHEDULER_NO_TASK != cadetp->reconnect_task)
+ if (NULL != cadetp->reconnect_task)
{
GNUNET_SCHEDULER_cancel (cadetp->reconnect_task);
- cadetp->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
+ cadetp->reconnect_task = NULL;
}
if (NULL != cadetp->mq)
{
@@ -625,7 +625,7 @@ cp_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
LOG (GNUNET_ERROR_TYPE_INFO,
"Retrying connection to collection point `%s'.\n",
GNUNET_i2s (&cadetp->peer_id));
- cadetp->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
+ cadetp->reconnect_task = NULL;
GNUNET_assert (NULL == cadetp->channel);
cadetp->channel =
GNUNET_CADET_channel_create (cadet, cadetp, &cadetp->peer_id,
@@ -740,7 +740,7 @@ get_cadet_peer (struct GNUNET_PeerIdentity pid)
GNUNET_APPLICATION_TYPE_SENSORDASHBOARD,
GNUNET_CADET_OPTION_RELIABLE);
cadetp->mq = cp_mq_create (cadetp);
- cadetp->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
+ cadetp->reconnect_task = NULL;
GNUNET_CONTAINER_DLL_insert (cadetp_head, cadetp_tail, cadetp);
return cadetp;
}
diff --git a/src/sensor/gnunet-service-sensor_update.c b/src/sensor/gnunet-service-sensor_update.c
index aa7716f1c3..a6390b6dd0 100644
--- a/src/sensor/gnunet-service-sensor_update.c
+++ b/src/sensor/gnunet-service-sensor_update.c
@@ -168,7 +168,7 @@ static int updating;
/**
* GNUnet scheduler task that starts the update check process.
*/
-static GNUNET_SCHEDULER_TaskIdentifier update_task;
+static struct GNUNET_SCHEDULER_Task * update_task;
/**
* Pointer to service reset function called when we have new sensor updates.
@@ -237,10 +237,10 @@ SENSOR_update_stop ()
up_default = NULL;
up = up_head;
- if (GNUNET_SCHEDULER_NO_TASK != update_task)
+ if (NULL != update_task)
{
GNUNET_SCHEDULER_cancel (update_task);
- update_task = GNUNET_SCHEDULER_NO_TASK;
+ update_task = NULL;
}
while (NULL != up)
{
@@ -390,7 +390,7 @@ check_for_updates (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct GNUNET_MessageHeader *msg;
size_t msg_size;
- update_task = GNUNET_SCHEDULER_NO_TASK;
+ update_task = NULL;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
if (GNUNET_YES == updating)
diff --git a/src/sensor/perf_pow_sign.c b/src/sensor/perf_pow_sign.c
index b553544907..d89fe46ef5 100644
--- a/src/sensor/perf_pow_sign.c
+++ b/src/sensor/perf_pow_sign.c
@@ -71,7 +71,7 @@ static int ok = 1;
/**
* Task used to shutdown / expire the test
*/
-static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
+static struct GNUNET_SCHEDULER_Task * shutdown_task;
/**
* Message to be exchanged
diff --git a/src/sensor/sensor_api.c b/src/sensor/sensor_api.c
index 628873f917..8d72d16cbe 100644
--- a/src/sensor/sensor_api.c
+++ b/src/sensor/sensor_api.c
@@ -121,7 +121,7 @@ struct GNUNET_SENSOR_IterateContext
/**
* Task responsible for timeout.
*/
- GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+ struct GNUNET_SCHEDULER_Task * timeout_task;
};
@@ -365,7 +365,7 @@ signal_sensor_iteration_timeout (void *cls,
GNUNET_SENSOR_SensorIterateCB cb;
void *cb_cls;
- ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ ic->timeout_task = NULL;
cb = ic->callback;
cb_cls = ic->callback_cls;
GNUNET_SENSOR_iterate_cancel (ic);
@@ -417,10 +417,10 @@ GNUNET_SENSOR_iterate_cancel (struct GNUNET_SENSOR_IterateContext *ic)
ic->callback_cls = NULL;
return;
}
- if (GNUNET_SCHEDULER_NO_TASK != ic->timeout_task)
+ if (NULL != ic->timeout_task)
{
GNUNET_SCHEDULER_cancel (ic->timeout_task);
- ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ ic->timeout_task = NULL;
}
GNUNET_CONTAINER_DLL_remove (h->ic_head, h->ic_tail, ic);
GNUNET_free (ic);
diff --git a/src/sensor/sensor_util_lib.c b/src/sensor/sensor_util_lib.c
index fd5337343a..381465d229 100644
--- a/src/sensor/sensor_util_lib.c
+++ b/src/sensor/sensor_util_lib.c
@@ -274,7 +274,7 @@ load_sensor_from_cfg (struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_free (dummy);
}
//execution task
- sensor->execution_task = GNUNET_SCHEDULER_NO_TASK;
+ sensor->execution_task = NULL;
//running
sensor->running = GNUNET_NO;
return sensor;
@@ -479,10 +479,10 @@ destroy_sensor (void *cls, const struct GNUNET_HashCode *key, void *value)
{
struct GNUNET_SENSOR_SensorInfo *sensor = value;
- if (GNUNET_SCHEDULER_NO_TASK != sensor->execution_task)
+ if (NULL != sensor->execution_task)
{
GNUNET_SCHEDULER_cancel (sensor->execution_task);
- sensor->execution_task = GNUNET_SCHEDULER_NO_TASK;
+ sensor->execution_task = NULL;
}
if (NULL != sensor->gnunet_stat_get_handle)
{
diff --git a/src/sensor/sensor_util_lib_crypto.c b/src/sensor/sensor_util_lib_crypto.c
index 41cba19915..154b7667ce 100644
--- a/src/sensor/sensor_util_lib_crypto.c
+++ b/src/sensor/sensor_util_lib_crypto.c
@@ -65,7 +65,7 @@ struct GNUNET_SENSOR_crypto_pow_context
/**
* Task that calculates the proof-of-work
*/
- GNUNET_SCHEDULER_TaskIdentifier calculate_pow_task;
+ struct GNUNET_SCHEDULER_Task * calculate_pow_task;
/**
* Size of msg (allocated after this struct)
@@ -157,7 +157,7 @@ calculate_pow (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
cx->matching_bits))
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Found pow %" PRIu64 ".\n", cx->pow);
- cx->calculate_pow_task = GNUNET_SCHEDULER_NO_TASK;
+ cx->calculate_pow_task = NULL;
result_block =
GNUNET_malloc (sizeof (struct GNUNET_SENSOR_crypto_pow_block) +
cx->msg_size);
@@ -197,10 +197,10 @@ void
GNUNET_SENSOR_crypto_pow_sign_cancel (struct GNUNET_SENSOR_crypto_pow_context
*cx)
{
- if (GNUNET_SCHEDULER_NO_TASK != cx->calculate_pow_task)
+ if (NULL != cx->calculate_pow_task)
{
GNUNET_SCHEDULER_cancel (cx->calculate_pow_task);
- cx->calculate_pow_task = GNUNET_SCHEDULER_NO_TASK;
+ cx->calculate_pow_task = NULL;
}
GNUNET_free (cx);
cx = NULL;
diff --git a/src/sensor/test_gnunet-service-sensor_reporting.c b/src/sensor/test_gnunet-service-sensor_reporting.c
index 4a58647ad9..dd9a2125ae 100644
--- a/src/sensor/test_gnunet-service-sensor_reporting.c
+++ b/src/sensor/test_gnunet-service-sensor_reporting.c
@@ -89,7 +89,7 @@ struct TestPeer
/**
* GNUNET scheduler task that forces the anomaly after a stabilization delay
*/
- GNUNET_SCHEDULER_TaskIdentifier delay_task;
+ struct GNUNET_SCHEDULER_Task * delay_task;
};
@@ -152,7 +152,7 @@ static struct GNUNET_PEERSTORE_Handle *peerstore;
/**
* Task used to shutdown / expire the test
*/
-static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
+static struct GNUNET_SCHEDULER_Task * shutdown_task;
/**
* Status of the test to be returned by main()
@@ -163,10 +163,10 @@ static int ok = 1;
static void
destroy_peer (struct TestPeer *peer)
{
- if (GNUNET_SCHEDULER_NO_TASK != peer->delay_task)
+ if (NULL != peer->delay_task)
{
GNUNET_SCHEDULER_cancel (peer->delay_task);
- peer->delay_task = GNUNET_SCHEDULER_NO_TASK;
+ peer->delay_task = NULL;
}
if (NULL != peer->sensor_op)
{
@@ -280,7 +280,7 @@ force_anomaly_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct TestPeer *peer = cls;
- peer->delay_task = GNUNET_SCHEDULER_NO_TASK;
+ peer->delay_task = NULL;
GNUNET_SENSOR_force_anomaly (peer->sensor, (char *) sensor_name, GNUNET_YES,
NULL, NULL);
}
@@ -481,7 +481,7 @@ peer_info_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op,
peer = GNUNET_new (struct TestPeer);
peer->testbed_peer = testbed_peer;
- peer->delay_task = GNUNET_SCHEDULER_NO_TASK;
+ peer->delay_task = NULL;
GNUNET_CRYPTO_get_peer_identity (pinfo->result.cfg, &peer->peer_id);
if (NULL == peer_head) /* First peer (collection point) */
{
diff --git a/src/sensor/test_pow_sign.c b/src/sensor/test_pow_sign.c
index 71ab6af817..b3039ff25e 100644
--- a/src/sensor/test_pow_sign.c
+++ b/src/sensor/test_pow_sign.c
@@ -66,7 +66,7 @@ static int ok = 1;
/**
* Task used to shutdown / expire the test
*/
-static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
+static struct GNUNET_SCHEDULER_Task * shutdown_task;
/**
* Message to be exchanged