From: Volker Lendecke Date: Fri, 2 Aug 2019 12:33:22 +0000 (+0200) Subject: smbd: Do not exceed the req's max timeout in setup_poll_open() X-Git-Tag: tdb-1.4.2~247 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1bc7d18b5f97d9b7e299df2107321601178aed83;p=thirdparty%2Fsamba.git smbd: Do not exceed the req's max timeout in setup_poll_open() 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 6e88b815988..f477a4fed09 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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) {