From 7e9e4e320d6eee5bf6afd876b282609712cb72db Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 22 Jan 2017 00:46:03 +0100 Subject: [PATCH] use new SCHEDULER_add_at API where applicable --- src/cadet/gnunet-service-cadet-new_tunnels.c | 6 ++-- src/core/gnunet-service-core_sessions.c | 12 +++---- src/dht/gnunet-service-dht_clients.c | 15 ++++---- src/fragmentation/fragmentation.c | 5 +-- src/fs/gnunet-service-fs_pe.c | 8 ++--- src/nse/gnunet-service-nse.c | 34 +++++++++---------- src/topology/gnunet-daemon-topology.c | 6 ++-- .../gnunet-service-transport_manipulation.c | 20 +++++------ .../gnunet-service-transport_neighbours.c | 6 ++-- 9 files changed, 55 insertions(+), 57 deletions(-) diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c b/src/cadet/gnunet-service-cadet-new_tunnels.c index 111adffde..178577b46 100644 --- a/src/cadet/gnunet-service-cadet-new_tunnels.c +++ b/src/cadet/gnunet-service-cadet-new_tunnels.c @@ -1673,9 +1673,9 @@ connection_ready_cb (void *cls, if (NULL == t->kx_task) { t->kx_task - = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (t->next_kx_attempt), - &retry_kx, - t); + = GNUNET_SCHEDULER_add_at (t->next_kx_attempt, + &retry_kx, + t); } break; case CADET_TUNNEL_KEY_OK: diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c index 036fd1425..6687b4819 100644 --- a/src/core/gnunet-service-core_sessions.c +++ b/src/core/gnunet-service-core_sessions.c @@ -90,9 +90,9 @@ struct Session /** * Key exchange state for this peer. - */ + */ struct GSC_KeyExchangeInfo *kx; - + /** * Head of list of requests from clients for transmission to * this peer. @@ -725,10 +725,10 @@ try_transmission (struct Session *session) GNUNET_YES)); if (NULL != session->cork_task) GNUNET_SCHEDULER_cancel (session->cork_task); - session->cork_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (min_deadline), - &pop_cork_task, - session); + session->cork_task + = GNUNET_SCHEDULER_add_at (min_deadline, + &pop_cork_task, + session); } else { diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index df56c010a..5ba4e5820 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c @@ -426,19 +426,20 @@ transmit_next_request_task (void *cls) delay = GNUNET_TIME_absolute_get_remaining (cqr->retry_time); if (delay.rel_value_us > 0) { - cqr->hnode = - GNUNET_CONTAINER_heap_insert (retry_heap, + cqr->hnode + = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, cqr->retry_time.abs_value_us); - retry_task = - GNUNET_SCHEDULER_add_delayed (delay, - &transmit_next_request_task, - NULL); + retry_task + = GNUNET_SCHEDULER_add_at (cqr->retry_time, + &transmit_next_request_task, + NULL); return; } transmit_request (cqr); cqr->hnode - = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, + = GNUNET_CONTAINER_heap_insert (retry_heap, + cqr, cqr->retry_time.abs_value_us); } } diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c index 02444cf14..f68635100 100644 --- a/src/fragmentation/fragmentation.c +++ b/src/fragmentation/fragmentation.c @@ -373,8 +373,9 @@ GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc) fc->proc_busy = GNUNET_NO; GNUNET_assert (fc->task == NULL); fc->task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining - (fc->delay_until), &transmit_next, fc); + GNUNET_SCHEDULER_add_at (fc->delay_until, + &transmit_next, + fc); } diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index e8ce77904..12b04dcd1 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c @@ -427,10 +427,10 @@ schedule_peer_transmission (void *cls) gettext_noop ("# delay heap timeout (ms)"), delay.rel_value_us / 1000LL, GNUNET_NO); - pp->task = - GNUNET_SCHEDULER_add_delayed (delay, - &schedule_peer_transmission, - pp); + pp->task + = GNUNET_SCHEDULER_add_at (rp->earliest_transmission, + &schedule_peer_transmission, + pp); return; } #if INSANE_STATISTICS diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 4d54a740b..e35115e31 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -437,7 +437,7 @@ handle_start (void *cls, GNUNET_notification_context_add (nc, mq); setup_estimate_message (&em); - env = GNUNET_MQ_msg_copy (&em.header); + env = GNUNET_MQ_msg_copy (&em.header); GNUNET_MQ_send (mq, env); GNUNET_SERVICE_client_continue (client); @@ -607,14 +607,14 @@ transmit_task_cb (void *cls) struct NSEPeerEntry *peer_entry = cls; unsigned int idx; struct GNUNET_MQ_Envelope *env; - + peer_entry->transmit_task = NULL; idx = estimate_index; if (GNUNET_NO == peer_entry->previous_round) { idx = (idx + HISTORY_SIZE - 1) % HISTORY_SIZE; peer_entry->previous_round = GNUNET_YES; - peer_entry->transmit_task + peer_entry->transmit_task = GNUNET_SCHEDULER_add_delayed (get_transmit_delay (0), &transmit_task_cb, peer_entry); @@ -652,12 +652,12 @@ transmit_task_cb (void *cls) GNUNET_NO); #if ENABLE_NSE_HISTOGRAM peer_entry->transmitted_messages++; - peer_entry->last_transmitted_size + peer_entry->last_transmitted_size = ntohl(size_estimate_messages[idx].matching_bits); #endif env = GNUNET_MQ_msg_copy (&size_estimate_messages[idx].header); GNUNET_MQ_send (peer_entry->mq, - env); + env); } @@ -811,11 +811,10 @@ update_flood_message (void *cls) GNUNET_CONTAINER_multipeermap_iterate (peers, &schedule_current_round, NULL); - flood_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining - (next_timestamp), - &update_flood_message, - NULL); + flood_task + = GNUNET_SCHEDULER_add_at (next_timestamp, + &update_flood_message, + NULL); } @@ -1012,7 +1011,7 @@ update_flood_times (void *cls, { /* still stuck in previous round, no point to update, check that * we are active here though... */ - if (NULL == peer_entry->transmit_task) + if (NULL == peer_entry->transmit_task) { GNUNET_break (0); } @@ -1034,7 +1033,7 @@ update_flood_times (void *cls, /** * Core handler for size estimate flooding messages. * - * @param cls peer this message is from + * @param cls peer this message is from * @param incoming_flood received message */ static void @@ -1169,7 +1168,7 @@ handle_p2p_estimate (void *cls, /* push back our result now, that peer is spreading bad information... */ if (NULL != peer_entry->transmit_task) GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); - peer_entry->transmit_task + peer_entry->transmit_task = GNUNET_SCHEDULER_add_now (&transmit_task_cb, peer_entry); /* Not closer than our most recent message, no need to do work here */ @@ -1431,11 +1430,10 @@ core_init (void *cls, current_timestamp); estimate_count++; } - flood_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining - (next_timestamp), - &update_flood_message, - NULL); + flood_task + = GNUNET_SCHEDULER_add_at (next_timestamp, + &update_flood_message, + NULL); } diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index d48f07e71..067ebce23 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -534,10 +534,10 @@ schedule_next_hello (void *cls) 1, GNUNET_NO); /* prepare to send the next one */ - if (NULL != pl->hello_delay_task) - GNUNET_SCHEDULER_cancel (pl->hello_delay_task); pl->next_hello_allowed = GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); + if (NULL != pl->hello_delay_task) + GNUNET_SCHEDULER_cancel (pl->hello_delay_task); pl->hello_delay_task = GNUNET_SCHEDULER_add_now (&schedule_next_hello, pl); @@ -1022,7 +1022,7 @@ check_hello (void *cls, const struct GNUNET_HELLO_Message *message) { struct GNUNET_PeerIdentity pid; - + if (GNUNET_OK != GNUNET_HELLO_get_id (message, &pid)) diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c index f198d6e49..e68753583 100644 --- a/src/transport/gnunet-service-transport_manipulation.c +++ b/src/transport/gnunet-service-transport_manipulation.c @@ -219,7 +219,6 @@ send_delayed (void *cls) struct DelayQueueEntry *dqe = cls; struct DelayQueueEntry *next; struct TM_Peer *tmp = dqe->tmp; - struct GNUNET_TIME_Relative delay; GNUNET_break (GNUNET_YES == GST_neighbours_test_connected (&dqe->id)); @@ -233,9 +232,9 @@ send_delayed (void *cls) if (NULL != next) { /* More delayed messages */ - delay = GNUNET_TIME_absolute_get_remaining(next->sent_at); - tmp->send_delay_task = GNUNET_SCHEDULER_add_delayed(delay, - &send_delayed, next); + tmp->send_delay_task = GNUNET_SCHEDULER_add_at (next->sent_at, + &send_delayed, + next); } } else @@ -249,10 +248,9 @@ send_delayed (void *cls) if (NULL != next) { /* More delayed messages */ - delay = GNUNET_TIME_absolute_get_remaining(next->sent_at); - generic_send_delay_task = GNUNET_SCHEDULER_add_delayed (delay, - &send_delayed, - next); + generic_send_delay_task = GNUNET_SCHEDULER_add_at (next->sent_at, + &send_delayed, + next); } } GST_neighbours_send (&dqe->id, @@ -503,9 +501,9 @@ GST_manipulation_peer_disconnect (const struct GNUNET_PeerIdentity *peer) generic_send_delay_task = NULL; if (NULL != generic_dqe_head) generic_send_delay_task - = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(generic_dqe_head->sent_at), - &send_delayed, - generic_dqe_head); + = GNUNET_SCHEDULER_add_at (generic_dqe_head->sent_at, + &send_delayed, + generic_dqe_head); } } diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index e1e4f56f8..3952a728e 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -735,9 +735,9 @@ set_state_and_timeout (struct NeighbourMapEntry *n, { /* new timeout is earlier, reschedule master task */ GNUNET_SCHEDULER_cancel (n->task); - n->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (timeout), - &master_task, - n); + n->task = GNUNET_SCHEDULER_add_at (timeout, + &master_task, + n); } n->timeout = timeout; GNUNET_log (GNUNET_ERROR_TYPE_INFO, -- 2.25.1