From: Volker Lendecke Date: Wed, 13 Mar 2024 15:19:48 +0000 (+0100) Subject: lib: Remove timeval_set() X-Git-Tag: tdb-1.4.11~1374 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7edf5467fc77cc1039c0ef9fd4579bfb7333c159;p=thirdparty%2Fsamba.git 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 Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Fri Mar 22 06:07:42 UTC 2024 on atb-devel-224 --- diff --git a/lib/util/time.c b/lib/util/time.c index fe2a2b499f5..d2bf2454e31 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -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 */ diff --git a/lib/util/time.h b/lib/util/time.h index cc4fd98771c..1180dd0cfc4 100644 --- a/lib/util/time.h +++ b/lib/util/time.h @@ -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 */ diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 46165e8fbfb..807b7f52248 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -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); diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c index 6613e8f9f55..d1e95bb083a 100644 --- a/source3/printing/queue_process.c +++ b/source3/printing/queue_process.c @@ -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; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index bd397376d26..ae47d130650 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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; } diff --git a/source3/smbd/smb2_process.c b/source3/smbd/smb2_process.c index 2783ac23822..482c448e81b 100644 --- a/source3/smbd/smb2_process.c +++ b/source3/smbd/smb2_process.c @@ -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); } diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c index f26fce77a23..dd0ba880fd1 100644 --- a/source3/smbd/smb2_setinfo.c +++ b/source3/smbd/smb2_setinfo.c @@ -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))) { diff --git a/source3/torture/msg_sink.c b/source3/torture/msg_sink.c index 3c3dda3c779..d61dd259d62 100644 --- a/source3/torture/msg_sink.c +++ b/source3/torture/msg_sink.c @@ -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; diff --git a/source3/torture/msg_source.c b/source3/torture/msg_source.c index e718018be98..6fb23f72252 100644 --- a/source3/torture/msg_source.c +++ b/source3/torture/msg_source.c @@ -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; diff --git a/source3/utils/net_g_lock.c b/source3/utils/net_g_lock.c index a1000284102..30dda0116a4 100644 --- a/source3/utils/net_g_lock.c +++ b/source3/utils/net_g_lock.c @@ -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"), diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c index 5d1314ec37a..92f6ebf374b 100644 --- a/source3/utils/net_registry.c +++ b/source3/utils/net_registry.c @@ -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)) { diff --git a/source3/winbindd/winbindd_cred_cache.c b/source3/winbindd/winbindd_cred_cache.c index 59daaffbd25..a73afe483fb 100644 --- a/source3/winbindd/winbindd_cred_cache.c +++ b/source3/winbindd/winbindd_cred_cache.c @@ -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; diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index e63b4052fd8..fdb66d0e1c7 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -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;