mirror of
https://github.com/samba-team/samba.git
synced 2025-02-01 05:47:28 +03:00
lib: Remove timeval_set()
We have the same function in tevent, no need to duplicate code. More lines just due to clang-format. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Mar 22 06:07:42 UTC 2024 on atb-devel-224
This commit is contained in:
parent
a3e186b617
commit
7edf5467fc
@ -617,18 +617,6 @@ _PUBLIC_ struct timeval timeval_current(void)
|
||||
return tv;
|
||||
}
|
||||
|
||||
/**
|
||||
return a timeval struct with the given elements
|
||||
*/
|
||||
_PUBLIC_ struct timeval timeval_set(uint32_t secs, uint32_t usecs)
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_sec = secs;
|
||||
tv.tv_usec = usecs;
|
||||
return tv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
return a timeval ofs microseconds after tv
|
||||
*/
|
||||
|
@ -240,11 +240,6 @@ bool timeval_is_zero(const struct timeval *tv);
|
||||
*/
|
||||
struct timeval timeval_current(void);
|
||||
|
||||
/**
|
||||
return a timeval struct with the given elements
|
||||
*/
|
||||
struct timeval timeval_set(uint32_t secs, uint32_t usecs);
|
||||
|
||||
/**
|
||||
return a timeval ofs microseconds after tv
|
||||
*/
|
||||
|
@ -381,8 +381,12 @@ static int db_ctdb_transaction_start(struct db_context *db)
|
||||
/*
|
||||
* Wait a day, i.e. forever...
|
||||
*/
|
||||
status = g_lock_lock(ctx->lock_ctx, string_term_tdb_data(h->lock_name),
|
||||
G_LOCK_WRITE, timeval_set(86400, 0), NULL, NULL);
|
||||
status = g_lock_lock(ctx->lock_ctx,
|
||||
string_term_tdb_data(h->lock_name),
|
||||
G_LOCK_WRITE,
|
||||
tevent_timeval_set(86400, 0),
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("g_lock_lock failed: %s\n", nt_errstr(status)));
|
||||
TALLOC_FREE(h);
|
||||
|
@ -186,10 +186,13 @@ static bool printing_subsystem_queue_tasks(struct bq_state *state)
|
||||
return true;
|
||||
}
|
||||
|
||||
state->housekeep = event_add_idle(state->ev, NULL,
|
||||
timeval_set(housekeeping_period, 0),
|
||||
"print_queue_housekeeping",
|
||||
print_queue_housekeeping, state);
|
||||
state->housekeep = event_add_idle(
|
||||
state->ev,
|
||||
NULL,
|
||||
tevent_timeval_set(housekeeping_period, 0),
|
||||
"print_queue_housekeeping",
|
||||
print_queue_housekeeping,
|
||||
state);
|
||||
if (state->housekeep == NULL) {
|
||||
DEBUG(0,("Could not add print_queue_housekeeping event\n"));
|
||||
return false;
|
||||
|
@ -3206,7 +3206,7 @@ static void schedule_defer_open(struct share_mode_lock *lck,
|
||||
* measure here in case the other smbd is stuck
|
||||
* somewhere else. */
|
||||
|
||||
timeout = timeval_set(OPLOCK_BREAK_TIMEOUT*2, 0);
|
||||
timeout = tevent_timeval_set(OPLOCK_BREAK_TIMEOUT * 2, 0);
|
||||
|
||||
if (request_timed_out(req, timeout)) {
|
||||
return;
|
||||
@ -3230,7 +3230,7 @@ static void schedule_async_open_timer(struct tevent_context *ev,
|
||||
static void schedule_async_open(struct smb_request *req)
|
||||
{
|
||||
struct deferred_open_record *open_rec = NULL;
|
||||
struct timeval timeout = timeval_set(20, 0);
|
||||
struct timeval timeout = tevent_timeval_set(20, 0);
|
||||
bool ok;
|
||||
|
||||
if (request_timed_out(req, timeout)) {
|
||||
@ -4184,11 +4184,11 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
|
||||
* the oplock got removed.
|
||||
*/
|
||||
|
||||
setup_poll_open(
|
||||
req,
|
||||
&fsp->file_id,
|
||||
timeval_set(OPLOCK_BREAK_TIMEOUT*2, 0),
|
||||
timeval_set(1, 0));
|
||||
setup_poll_open(req,
|
||||
&fsp->file_id,
|
||||
tevent_timeval_set(OPLOCK_BREAK_TIMEOUT * 2,
|
||||
0),
|
||||
tevent_timeval_set(1, 0));
|
||||
|
||||
return NT_STATUS_SHARING_VIOLATION;
|
||||
}
|
||||
|
@ -2020,26 +2020,37 @@ void smbd_process(struct tevent_context *ev_ctx,
|
||||
MSG_DEBUG, debug_message);
|
||||
|
||||
#if defined(WITH_SMB1SERVER)
|
||||
if ((lp_keepalive() != 0)
|
||||
&& !(event_add_idle(ev_ctx, NULL,
|
||||
timeval_set(lp_keepalive(), 0),
|
||||
"keepalive", keepalive_fn,
|
||||
sconn))) {
|
||||
if ((lp_keepalive() != 0) &&
|
||||
!(event_add_idle(ev_ctx,
|
||||
NULL,
|
||||
tevent_timeval_set(lp_keepalive(), 0),
|
||||
"keepalive",
|
||||
keepalive_fn,
|
||||
sconn)))
|
||||
{
|
||||
DEBUG(0, ("Could not add keepalive event\n"));
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(event_add_idle(ev_ctx, NULL,
|
||||
timeval_set(IDLE_CLOSED_TIMEOUT, 0),
|
||||
"deadtime", deadtime_fn, sconn))) {
|
||||
if (!(event_add_idle(ev_ctx,
|
||||
NULL,
|
||||
tevent_timeval_set(IDLE_CLOSED_TIMEOUT, 0),
|
||||
"deadtime",
|
||||
deadtime_fn,
|
||||
sconn)))
|
||||
{
|
||||
DEBUG(0, ("Could not add deadtime event\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!(event_add_idle(ev_ctx, NULL,
|
||||
timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
|
||||
"housekeeping", housekeeping_fn, sconn))) {
|
||||
if (!(event_add_idle(ev_ctx,
|
||||
NULL,
|
||||
tevent_timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
|
||||
"housekeeping",
|
||||
housekeeping_fn,
|
||||
sconn)))
|
||||
{
|
||||
DEBUG(0, ("Could not add housekeeping event\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ static struct tevent_req *delay_rename_for_lease_break(struct tevent_req *req,
|
||||
|
||||
tevent_req_set_callback(subreq, defer_rename_done, rename_state);
|
||||
|
||||
timeout = timeval_set(OPLOCK_BREAK_TIMEOUT*2, 0);
|
||||
timeout = tevent_timeval_set(OPLOCK_BREAK_TIMEOUT * 2, 0);
|
||||
if (!tevent_req_set_endtime(subreq,
|
||||
ev,
|
||||
timeval_sum(&smb2req->request_time, &timeout))) {
|
||||
|
@ -266,8 +266,8 @@ int main(void)
|
||||
|
||||
printf("server_id: %s\n", server_id_str_buf(id, &tmp));
|
||||
|
||||
req = msgcount_send(ev, ev, msg_ctx, MSG_SMB_NOTIFY,
|
||||
timeval_set(1, 0));
|
||||
req = msgcount_send(
|
||||
ev, ev, msg_ctx, MSG_SMB_NOTIFY, tevent_timeval_set(1, 0));
|
||||
if (req == NULL) {
|
||||
perror("msgcount_send failed");
|
||||
return -1;
|
||||
|
@ -139,8 +139,12 @@ int main(int argc, const char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
req = source_send(ev, ev, msg_ctx, MSG_SMB_NOTIFY,
|
||||
timeval_set(0, 10000), id);
|
||||
req = source_send(ev,
|
||||
ev,
|
||||
msg_ctx,
|
||||
MSG_SMB_NOTIFY,
|
||||
tevent_timeval_set(0, 10000),
|
||||
id);
|
||||
if (req == NULL) {
|
||||
perror("source_send failed");
|
||||
return -1;
|
||||
|
@ -83,13 +83,13 @@ static int net_g_lock_do(struct net_context *c, int argc, const char **argv)
|
||||
d_fprintf(stderr, _("g_lock_ctx_init failed\n"));
|
||||
return -1;
|
||||
}
|
||||
status = g_lock_lock(
|
||||
ctx,
|
||||
key,
|
||||
G_LOCK_WRITE,
|
||||
timeval_set(timeout / 1000, timeout % 1000),
|
||||
NULL,
|
||||
NULL);
|
||||
status = g_lock_lock(ctx,
|
||||
key,
|
||||
G_LOCK_WRITE,
|
||||
tevent_timeval_set(timeout / 1000,
|
||||
timeout % 1000),
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
d_fprintf(stderr,
|
||||
_("g_lock_lock failed: %s\n"),
|
||||
|
@ -616,7 +616,7 @@ static int net_registry_increment(struct net_context *c, int argc,
|
||||
status = g_lock_lock(ctx,
|
||||
lock_key,
|
||||
G_LOCK_WRITE,
|
||||
timeval_set(600, 0),
|
||||
tevent_timeval_set(600, 0),
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
|
@ -174,8 +174,10 @@ rekinit:
|
||||
new_start = time(NULL) +
|
||||
MAX(30, lp_winbind_cache_time());
|
||||
#endif
|
||||
add_krb5_ticket_gain_handler_event(entry,
|
||||
timeval_set(new_start, 0));
|
||||
add_krb5_ticket_gain_handler_event(
|
||||
entry,
|
||||
tevent_timeval_set(new_start,
|
||||
0));
|
||||
return;
|
||||
}
|
||||
TALLOC_FREE(entry->event);
|
||||
@ -250,8 +252,8 @@ rekinit:
|
||||
#endif
|
||||
/* ticket is destroyed here, we have to regain it
|
||||
* if it is possible */
|
||||
add_krb5_ticket_gain_handler_event(entry,
|
||||
timeval_set(new_start, 0));
|
||||
add_krb5_ticket_gain_handler_event(
|
||||
entry, tevent_timeval_set(new_start, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -280,18 +282,19 @@ done:
|
||||
&& (entry->renew_until <= expire_time)) {
|
||||
/* try to regain ticket 10 seconds before expiration */
|
||||
expire_time -= 10;
|
||||
add_krb5_ticket_gain_handler_event(entry,
|
||||
timeval_set(expire_time, 0));
|
||||
add_krb5_ticket_gain_handler_event(
|
||||
entry, tevent_timeval_set(expire_time, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry->refresh_time == 0) {
|
||||
entry->refresh_time = new_start;
|
||||
}
|
||||
entry->event = tevent_add_timer(global_event_context(), entry,
|
||||
timeval_set(new_start, 0),
|
||||
krb5_ticket_refresh_handler,
|
||||
entry);
|
||||
entry->event = tevent_add_timer(global_event_context(),
|
||||
entry,
|
||||
tevent_timeval_set(new_start, 0),
|
||||
krb5_ticket_refresh_handler,
|
||||
entry);
|
||||
|
||||
#endif
|
||||
}
|
||||
@ -371,7 +374,7 @@ static void krb5_ticket_gain_handler(struct tevent_context *event_ctx,
|
||||
retry_later:
|
||||
|
||||
#if defined(DEBUG_KRB5_TKT_RENEWAL)
|
||||
t = timeval_set(time(NULL) + 30, 0);
|
||||
t = tevent_timeval_set(time(NULL) + 30, 0);
|
||||
#else
|
||||
t = timeval_current_ofs(MAX(30, lp_winbind_cache_time()), 0);
|
||||
#endif
|
||||
@ -382,9 +385,9 @@ static void krb5_ticket_gain_handler(struct tevent_context *event_ctx,
|
||||
got_ticket:
|
||||
|
||||
#if defined(DEBUG_KRB5_TKT_RENEWAL)
|
||||
t = timeval_set(time(NULL) + 30, 0);
|
||||
t = tevent_timeval_set(time(NULL) + 30, 0);
|
||||
#else
|
||||
t = timeval_set(krb5_event_refresh_time(entry->refresh_time), 0);
|
||||
t = tevent_timeval_set(krb5_event_refresh_time(entry->refresh_time), 0);
|
||||
#endif
|
||||
|
||||
if (entry->refresh_time == 0) {
|
||||
@ -545,10 +548,11 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
|
||||
} else {
|
||||
/* Renew at 1/2 the ticket expiration time */
|
||||
#if defined(DEBUG_KRB5_TKT_RENEWAL)
|
||||
t = timeval_set(time(NULL)+30, 0);
|
||||
t = tevent_timeval_set(time(NULL) + 30, 0);
|
||||
#else
|
||||
t = timeval_set(krb5_event_refresh_time(ticket_end),
|
||||
0);
|
||||
t = tevent_timeval_set(krb5_event_refresh_time(
|
||||
ticket_end),
|
||||
0);
|
||||
#endif
|
||||
if (!entry->refresh_time) {
|
||||
entry->refresh_time = t.tv_sec;
|
||||
@ -659,9 +663,9 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
|
||||
} else {
|
||||
/* Renew at 1/2 the ticket expiration time */
|
||||
#if defined(DEBUG_KRB5_TKT_RENEWAL)
|
||||
t = timeval_set(time(NULL)+30, 0);
|
||||
t = tevent_timeval_set(time(NULL) + 30, 0);
|
||||
#else
|
||||
t = timeval_set(krb5_event_refresh_time(ticket_end), 0);
|
||||
t = tevent_timeval_set(krb5_event_refresh_time(ticket_end), 0);
|
||||
#endif
|
||||
if (entry->refresh_time == 0) {
|
||||
entry->refresh_time = t.tv_sec;
|
||||
|
@ -1285,7 +1285,7 @@ static bool calculate_next_machine_pwd_change(const char *domain,
|
||||
next_change = pass_last_set_time + timeout;
|
||||
DEBUG(10,("machine password still valid until: %s\n",
|
||||
http_timestring(talloc_tos(), next_change)));
|
||||
*t = timeval_set(next_change, 0);
|
||||
*t = tevent_timeval_set(next_change, 0);
|
||||
|
||||
if (lp_clustering()) {
|
||||
uint8_t randbuf;
|
||||
|
Loading…
x
Reference in New Issue
Block a user