From: Volker Lendecke Date: Fri, 24 Nov 2023 15:27:42 +0000 (+0100) Subject: profile: Fix rusage reporting X-Git-Tag: talloc-2.4.2~271 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e3b4073d3c7c50e63f2214912d091264c8c94035;p=thirdparty%2Fsamba.git profile: Fix rusage reporting getrusage already gives accumulated values, so add them to the tdb record after smbprofile_stats_accumulate. Maybe we should not zero out our internal copy after writing the tdb, this would save a call to smbprofile_stats_accumulate() once a second. Signed-off-by: Volker Lendecke Reviewed-by: Guenther Deschner --- diff --git a/source3/profile/profile.c b/source3/profile/profile.c index cf35db78773..0b02e36fcd0 100644 --- a/source3/profile/profile.c +++ b/source3/profile/profile.c @@ -233,6 +233,16 @@ void smbprofile_dump(void) pid = tevent_cached_getpid(); + ret = tdb_chainlock(smbprofile_state.internal.db->tdb, key); + if (ret != 0) { + return; + } + + tdb_parse_record(smbprofile_state.internal.db->tdb, + key, profile_stats_parser, &s); + + smbprofile_stats_accumulate(profile_p, &s); + #ifdef HAVE_GETRUSAGE ret = getrusage(RUSAGE_SELF, &rself); if (ret != 0) { @@ -247,16 +257,6 @@ void smbprofile_dump(void) rself.ru_stime.tv_usec; #endif /* HAVE_GETRUSAGE */ - ret = tdb_chainlock(smbprofile_state.internal.db->tdb, key); - if (ret != 0) { - return; - } - - tdb_parse_record(smbprofile_state.internal.db->tdb, - key, profile_stats_parser, &s); - - smbprofile_stats_accumulate(profile_p, &s); - tdb_store(smbprofile_state.internal.db->tdb, key, (TDB_DATA) { .dptr = (uint8_t *)profile_p,