]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Do not exceed the req's max timeout in setup_poll_open()
authorVolker Lendecke <vl@samba.org>
Fri, 2 Aug 2019 12:33:22 +0000 (14:33 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 7 Aug 2019 23:45:50 +0000 (23:45 +0000)
This will become important in the next commits when the SMB1 sharing
violation delay will use this. We want to be able to reduce the
timeout to less than 200msec, see the next commits.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c

index 6e88b8159886c7df52af12b5aaacf01e7a4902cb..f477a4fed09d07f1336b760973f7a32d337f8989 100644 (file)
@@ -2517,7 +2517,7 @@ static bool setup_poll_open(
 
        bool ok;
        struct deferred_open_record *open_rec = NULL;
-       /* Maximum wait time. */
+       struct timeval endtime, next_interval;
 
        if (request_timed_out(req, max_timeout)) {
                return false;
@@ -2531,10 +2531,19 @@ static bool setup_poll_open(
        open_rec->xconn = req->xconn;
        open_rec->mid = req->mid;
 
+       /*
+        * Make sure open_rec->te does not come later than the
+        * request's maximum endtime.
+        */
+
+       endtime = timeval_sum(&req->request_time, &max_timeout);
+       next_interval = timeval_current_ofs(interval.tv_sec, interval.tv_usec);
+       next_interval = timeval_min(&endtime, &next_interval);
+
        open_rec->te = tevent_add_timer(
                req->sconn->ev_ctx,
                open_rec,
-               timeval_current_ofs(interval.tv_sec, interval.tv_usec),
+               next_interval,
                poll_open_fn,
                open_rec);
        if (open_rec->te == NULL) {