summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-06-01 11:21:15 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-06-01 10:38:47 +0200
commit56e72337b01216dc7cba418f040a5cc928e5fc6f (patch)
tree7d64feee26bfeede2ab07ea6045ac11ebb4ea3c2 /source3
parent9bd695c83f43cacfc08566f3c18db44b61f7ed75 (diff)
downloadsamba-56e72337b01216dc7cba418f040a5cc928e5fc6f.tar.gz
samba-56e72337b01216dc7cba418f040a5cc928e5fc6f.tar.bz2
samba-56e72337b01216dc7cba418f040a5cc928e5fc6f.zip
lib/util/time.c: timeval_current_ofs_msec
Several places want "milliseconds from current time", and several were simply doing "msec * 1000" which can (and does in one place) result in a usec value over 1 a million. Using a helper to do this is safer and more readable. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/async_smb.c3
-rw-r--r--source3/nmbd/nmbd_processlogon.c3
-rw-r--r--source3/rpc_client/rpc_transport_tstream.c6
-rw-r--r--source3/smbd/blocking.c3
-rw-r--r--source3/smbd/smb2_lock.c4
5 files changed, 7 insertions, 12 deletions
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 3ed38718c1..8fdcac47a9 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -340,8 +340,7 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
state->iov_count = iov_count + 3;
if (cli->timeout) {
- endtime = timeval_current_ofs(cli->timeout / 1000,
- (cli->timeout % 1000) * 1000);
+ endtime = timeval_current_ofs_msec(cli->timeout);
if (!tevent_req_set_endtime(result, ev, endtime)) {
tevent_req_nomem(NULL, result);
}
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index 790e1c3ce1..25cdcc6970 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -604,8 +604,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
source_name, source_addr,
lp_init_logon_delay()));
- when = timeval_current_ofs(0,
- lp_init_logon_delay() * 1000);
+ when = timeval_current_ofs_msec(lp_init_logon_delay());
p->locked = true;
event_add_timed(nmbd_event_context(),
NULL,
diff --git a/source3/rpc_client/rpc_transport_tstream.c b/source3/rpc_client/rpc_transport_tstream.c
index e62ab4b2bb..488c093d3b 100644
--- a/source3/rpc_client/rpc_transport_tstream.c
+++ b/source3/rpc_client/rpc_transport_tstream.c
@@ -202,7 +202,7 @@ static struct tevent_req *rpc_tstream_read_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- endtime = timeval_current_ofs(0, transp->timeout * 1000);
+ endtime = timeval_current_ofs_msec(transp->timeout);
if (!tevent_req_set_endtime(subreq, ev, endtime)) {
goto fail;
}
@@ -286,7 +286,7 @@ static struct tevent_req *rpc_tstream_write_send(TALLOC_CTX *mem_ctx,
goto fail;
}
- endtime = timeval_current_ofs(0, transp->timeout * 1000);
+ endtime = timeval_current_ofs_msec(transp->timeout);
if (!tevent_req_set_endtime(subreq, ev, endtime)) {
goto fail;
}
@@ -374,7 +374,7 @@ static struct tevent_req *rpc_tstream_trans_send(TALLOC_CTX *mem_ctx,
state->req.iov_base = discard_const_p(void *, data);
state->max_rdata_len = max_rdata_len;
- endtime = timeval_current_ofs(0, transp->timeout * 1000);
+ endtime = timeval_current_ofs_msec(transp->timeout);
subreq = tstream_writev_queue_send(state, ev,
transp->stream,
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index ca4106b346..fd77e3d15b 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -208,8 +208,7 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
blr->expire_time.tv_sec = 0;
blr->expire_time.tv_usec = 0; /* Never expire. */
} else {
- blr->expire_time = timeval_current_ofs(lock_timeout/1000,
- (lock_timeout % 1000) * 1000);
+ blr->expire_time = timeval_current_ofs_msec(lock_timeout);
}
blr->lock_num = lock_num;
blr->smblctx = smblctx;
diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c
index 712558481c..5d615e1bed 100644
--- a/source3/smbd/smb2_lock.c
+++ b/source3/smbd/smb2_lock.c
@@ -628,9 +628,7 @@ bool push_blocking_lock_request_smb2( struct byte_range_lock *br_lck,
blr->expire_time.tv_sec = 0;
blr->expire_time.tv_usec = 0; /* Never expire. */
} else {
- blr->expire_time = timeval_current_ofs(
- lock_timeout/1000,
- (lock_timeout % 1000) * 1000);
+ blr->expire_time = timeval_current_ofs_msec(lock_timeout);
}
blr->lock_num = lock_num;