]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/lib: add next helper variable in server_id_watch_*
authorRalph Boehme <slow@samba.org>
Thu, 25 Apr 2024 13:24:57 +0000 (15:24 +0200)
committerJule Anger <janger@samba.org>
Wed, 2 Oct 2024 14:34:13 +0000 (14:34 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
(cherry picked from commit d76edcd48437715c7541b5b1e6a56245c25f460b)

source3/lib/server_id_watch.c

index f0189e0e896ac4ff11011259bb45a8d12a2455d1..50b35f27b3e29a04ec7ecf656424ed9de1bc96cb 100644 (file)
@@ -27,6 +27,7 @@
 struct server_id_watch_state {
        struct tevent_context *ev;
        struct server_id pid;
+       struct timeval start;
 };
 
 static void server_id_watch_waited(struct tevent_req *subreq);
@@ -37,6 +38,7 @@ struct tevent_req *server_id_watch_send(TALLOC_CTX *mem_ctx,
 {
        struct tevent_req *req, *subreq;
        struct server_id_watch_state *state;
+       struct timeval next;
 
        req = tevent_req_create(mem_ctx, &state, struct server_id_watch_state);
        if (req == NULL) {
@@ -44,14 +46,15 @@ struct tevent_req *server_id_watch_send(TALLOC_CTX *mem_ctx,
        }
        state->ev = ev;
        state->pid = pid;
+       state->start = tevent_timeval_current();
 
        if (!serverid_exists(&state->pid)) {
                tevent_req_done(req);
                return tevent_req_post(req, ev);
        }
 
-       subreq = tevent_wakeup_send(
-               state, ev, tevent_timeval_current_ofs(0, 500000));
+       next = tevent_timeval_add(&state->start, 0, 500000);
+       subreq = tevent_wakeup_send(state, ev, next);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -66,6 +69,8 @@ static void server_id_watch_waited(struct tevent_req *subreq)
                subreq, struct tevent_req);
        struct server_id_watch_state *state = tevent_req_data(
                req, struct server_id_watch_state);
+       struct timeval now;
+       struct timeval next;
        bool ok;
 
        ok = tevent_wakeup_recv(subreq);
@@ -80,8 +85,9 @@ static void server_id_watch_waited(struct tevent_req *subreq)
                return;
        }
 
-       subreq = tevent_wakeup_send(
-               state, state->ev, tevent_timeval_current_ofs(0, 500000));
+       now = tevent_timeval_current();
+       next = tevent_timeval_add(&now, 0, 500000);
+       subreq = tevent_wakeup_send(state, state->ev, next);
        if (tevent_req_nomem(subreq, req)) {
                return;
        }