From: Volker Lendecke Date: Wed, 22 Nov 2023 15:12:01 +0000 (+0100) Subject: profile: Add number of sessions, tcons and files to smbstatus -P X-Git-Tag: tevent-0.17.0~342 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48c80e058a09927938aef8e721aa12d70f0dcb9b;p=thirdparty%2Fsamba.git profile: Add number of sessions, tcons and files to smbstatus -P Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme Reviewed-by: Guenther Deschner --- diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h index 689a84d9c8d..3354770efe7 100644 --- a/source3/include/smbprofile.h +++ b/source3/include/smbprofile.h @@ -476,6 +476,7 @@ struct smbprofile_global_state { struct tdb_wrap *db; struct tevent_context *ev; struct tevent_timer *te; + struct smbd_server_connection *sconn; } internal; struct { @@ -491,7 +492,8 @@ struct smbprofile_global_state { extern struct smbprofile_global_state smbprofile_state; void smbprofile_dump_schedule_timer(void); -void smbprofile_dump_setup(struct tevent_context *ev); +void smbprofile_dump_setup(struct tevent_context *ev, + struct smbd_server_connection *sconn); static inline void smbprofile_dump_schedule(void) { @@ -644,7 +646,8 @@ static inline bool smbprofile_dump_pending(void) return false; } -static inline void smbprofile_dump_setup(struct tevent_context *ev) +static inline void smbprofile_dump_setup(struct tevent_context *ev, + struct smbd_server_connection *sconn) { return; } diff --git a/source3/profile/profile.c b/source3/profile/profile.c index 8bc261361ff..d24a6382c92 100644 --- a/source3/profile/profile.c +++ b/source3/profile/profile.c @@ -163,10 +163,12 @@ out: return ok; } -void smbprofile_dump_setup(struct tevent_context *ev) +void smbprofile_dump_setup(struct tevent_context *ev, + struct smbd_server_connection *sconn) { TALLOC_FREE(smbprofile_state.internal.te); smbprofile_state.internal.ev = ev; + smbprofile_state.internal.sconn = sconn; } static void smbprofile_dump_timer(struct tevent_context *ev, @@ -174,7 +176,7 @@ static void smbprofile_dump_timer(struct tevent_context *ev, struct timeval current_time, void *private_data) { - smbprofile_dump(NULL); + smbprofile_dump(smbprofile_state.internal.sconn); } void smbprofile_dump_schedule_timer(void) diff --git a/source3/smbd/smb2_process.c b/source3/smbd/smb2_process.c index 67cc0978771..745985e5c0e 100644 --- a/source3/smbd/smb2_process.c +++ b/source3/smbd/smb2_process.c @@ -1738,6 +1738,7 @@ static void smbd_id_cache_kill(struct messaging_context *msg_ctx, struct smbd_tevent_trace_state { struct tevent_context *ev; TALLOC_CTX *frame; + struct smbd_server_connection *sconn; SMBPROFILE_BASIC_ASYNC_STATE(profile_idle); struct timeval before_wait_tv; struct timeval after_wait_tv; @@ -1844,7 +1845,7 @@ static void smbd_tevent_trace_callback_profile(enum tevent_trace_point point, * * Instead we want to sleep as long as nothing happens. */ - smbprofile_dump_setup(NULL); + smbprofile_dump_setup(NULL, NULL); } SMBPROFILE_BASIC_ASYNC_START(idle, profile_p, state->profile_idle); break; @@ -1856,12 +1857,12 @@ static void smbd_tevent_trace_callback_profile(enum tevent_trace_point point, * We need to flush our state after sleeping * (hopefully a long time). */ - smbprofile_dump(NULL); + smbprofile_dump(state->sconn); /* * future profiling events should trigger timers * on our main event context. */ - smbprofile_dump_setup(state->ev); + smbprofile_dump_setup(state->ev, state->sconn); } break; case TEVENT_TRACE_BEFORE_LOOP_ONCE: @@ -1923,6 +1924,7 @@ void smbd_process(struct tevent_context *ev_ctx, if (sconn == NULL) { exit_server("failed to create smbd_server_connection"); } + trace_state.sconn = sconn; client->sconn = sconn; sconn->client = client; @@ -2138,7 +2140,7 @@ void smbd_process(struct tevent_context *ev_ctx, exit(1); } - smbprofile_dump_setup(ev_ctx); + smbprofile_dump_setup(ev_ctx, sconn); if (!init_dptrs(sconn)) { exit_server("init_dptrs() failed");