libcli/cldap/cldap.c: don't hand huge values to tevent_timeval_add usecs
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 1 Jun 2011 02:50:08 +0000 (12:20 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 1 Jun 2011 08:38:47 +0000 (10:38 +0200)
state->request.delay is two million here, resulting in an invalid timeval.
Since tevent doesn't have a convenient wrapper to add arbitrary usecs,
do the arithmetic here (it's the sole caller of this function).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
libcli/cldap/cldap.c

index f5585c2b730e16d7cd0484233f4ed20f0d6700da..37b4f4913dbfc5beb1ccca7da6eb00458526f607 100644 (file)
@@ -626,7 +626,8 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
        now = tevent_timeval_current();
        end = now;
        for (i = 0; i < state->request.count; i++) {
-               end = tevent_timeval_add(&end, 0, state->request.delay);
+               end = tevent_timeval_add(&end, state->request.delay / 1000000,
+                                        state->request.delay % 1000000);
        }
 
        if (!tevent_req_set_endtime(req, state->caller.cldap->event.ctx, end)) {
@@ -688,7 +689,8 @@ static void cldap_search_state_queue_done(struct tevent_req *subreq)
                return;
        }
 
-       next = tevent_timeval_current_ofs(0, state->request.delay);
+       next = tevent_timeval_current_ofs(state->request.delay / 1000000,
+                                         state->request.delay % 1000000);
        subreq = tevent_wakeup_send(state,
                                    state->caller.cldap->event.ctx,
                                    next);