diff options
-rw-r--r-- | lib/util/time.c | 9 | ||||
-rw-r--r-- | lib/util/time.h | 5 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 14 | ||||
-rw-r--r-- | source3/smbd/fileio.c | 2 | ||||
-rw-r--r-- | source4/lib/socket/connect_multi.c | 2 | ||||
-rw-r--r-- | source4/libcli/raw/clitransport.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_open.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_write.c | 2 |
8 files changed, 26 insertions, 12 deletions
diff --git a/lib/util/time.c b/lib/util/time.c index de1553aff8..d8fd4a3dfc 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -589,6 +589,15 @@ _PUBLIC_ struct timeval timeval_current_ofs_msec(uint32_t msecs) } /** + return a timeval microseconds into the future +*/ +_PUBLIC_ struct timeval timeval_current_ofs_usec(uint32_t usecs) +{ + struct timeval tv = timeval_current(); + return timeval_add(&tv, usecs / 1000000, usecs % 1000000); +} + +/** compare two timeval structures. Return -1 if tv1 < tv2 Return 0 if tv1 == tv2 diff --git a/lib/util/time.h b/lib/util/time.h index 4e4f72f71f..1f7f57db77 100644 --- a/lib/util/time.h +++ b/lib/util/time.h @@ -218,6 +218,11 @@ _PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs); _PUBLIC_ struct timeval timeval_current_ofs_msec(uint32_t msecs); /** + return a timeval microseconds into the future +*/ +_PUBLIC_ struct timeval timeval_current_ofs_usec(uint32_t usecs); + +/** compare two timeval structures. Return -1 if tv1 < tv2 Return 0 if tv1 == tv2 diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 5d20d74404..5b01d11bc6 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -524,7 +524,7 @@ struct open_socket_out_state { struct sockaddr_storage ss; socklen_t salen; uint16_t port; - int wait_nsec; + int wait_usec; }; static void open_socket_out_connected(struct tevent_req *subreq); @@ -560,7 +560,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, state->ev = ev; state->ss = *pss; state->port = port; - state->wait_nsec = 10000; + state->wait_usec = 10000; state->salen = -1; state->fd = socket(state->ss.ss_family, SOCK_STREAM, 0); @@ -571,7 +571,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, talloc_set_destructor(state, open_socket_out_state_destructor); if (!tevent_req_set_endtime( - result, ev, timeval_current_ofs(0, timeout*1000))) { + result, ev, timeval_current_ofs_msec(timeout))) { goto fail; } @@ -608,7 +608,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, if ((subreq == NULL) || !tevent_req_set_endtime( subreq, state->ev, - timeval_current_ofs(0, state->wait_nsec))) { + timeval_current_ofs(0, state->wait_usec))) { goto fail; } tevent_req_set_callback(subreq, open_socket_out_connected, result); @@ -650,8 +650,8 @@ static void open_socket_out_connected(struct tevent_req *subreq) * retry */ - if (state->wait_nsec < 250000) { - state->wait_nsec *= 1.5; + if (state->wait_usec < 250000) { + state->wait_usec *= 1.5; } subreq = async_connect_send(state, state->ev, state->fd, @@ -662,7 +662,7 @@ static void open_socket_out_connected(struct tevent_req *subreq) } if (!tevent_req_set_endtime( subreq, state->ev, - timeval_current_ofs(0, state->wait_nsec))) { + timeval_current_ofs_usec(state->wait_usec))) { tevent_req_nterror(req, NT_STATUS_NO_MEMORY); return; } diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 5e0ea9041d..3b317f9a86 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -241,7 +241,7 @@ void trigger_write_time_update(struct files_struct *fsp) /* trigger the update 2 seconds later */ fsp->update_write_time_event = event_add_timed(server_event_context(), NULL, - timeval_current_ofs(0, delay), + timeval_current_ofs_usec(delay), update_write_time_handler, fsp); } diff --git a/source4/lib/socket/connect_multi.c b/source4/lib/socket/connect_multi.c index 300e5fb1e5..e3b58456c4 100644 --- a/source4/lib/socket/connect_multi.c +++ b/source4/lib/socket/connect_multi.c @@ -162,7 +162,7 @@ static void connect_multi_next_socket(struct composite_context *result) connect attempt state, so it will go away when this request completes */ event_add_timed(result->event_ctx, state, - timeval_current_ofs(0, MULTI_PORT_DELAY), + timeval_current_ofs_usec(MULTI_PORT_DELAY), connect_multi_timer, result); } } diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index 7a3993c79b..43316692a4 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -338,7 +338,7 @@ _PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport, transport->socket->event.te = event_add_timed(transport->socket->event.ctx, transport, - timeval_current_ofs(0, period), + timeval_current_ofs_usec(period), idle_handler, transport); } diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index dfe2f2aa62..d56bce58f7 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -1174,7 +1174,7 @@ static NTSTATUS pvfs_open_setup_retry(struct ntvfs_module_context *ntvfs, *final_timeout = timeval_add(&req->statistics.request_time, pvfs->oplock_break_timeout, 0); - end_time = timeval_current_ofs(0, (pvfs->sharing_violation_delay*4)/5); + end_time = timeval_current_ofs_usec((pvfs->sharing_violation_delay*4)/5); end_time = timeval_min(final_timeout, &end_time); } else { return NT_STATUS_INTERNAL_ERROR; diff --git a/source4/ntvfs/posix/pvfs_write.c b/source4/ntvfs/posix/pvfs_write.c index fb629a87fb..892d3dd749 100644 --- a/source4/ntvfs/posix/pvfs_write.c +++ b/source4/ntvfs/posix/pvfs_write.c @@ -64,7 +64,7 @@ static void pvfs_trigger_write_time_update(struct pvfs_file_handle *h) return; } - tv = timeval_current_ofs(0, pvfs->writetime_delay); + tv = timeval_current_ofs_usec(pvfs->writetime_delay); h->write_time.update_triggered = true; h->write_time.update_on_close = true; |