diff options
author | Stefan Metzmacher <metze@samba.org> | 2022-07-25 14:29:35 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2022-07-25 17:34:33 +0000 |
commit | 0f544f33633468b5d249a10dc901e88a3820a97a (patch) | |
tree | 9d41cc0ab7d19c41cf913d2e29a421715e20160d /lib | |
parent | 94e130fb866d4b7bdbeacb4152093d827d5eb2bb (diff) | |
download | samba-0f544f33633468b5d249a10dc901e88a3820a97a.tar.gz |
lib/util: make use of tevent_cached_getpid() in performance critical code
This avoids wasting getpid() calls in a lot of places...
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/genrand_util.c | 3 | ||||
-rw-r--r-- | lib/util/util.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/util/genrand_util.c b/lib/util/genrand_util.c index 9aa35de3ae7..fdc2654a204 100644 --- a/lib/util/genrand_util.c +++ b/lib/util/genrand_util.c @@ -21,6 +21,7 @@ #include "replace.h" #include "system/locale.h" +#include <tevent.h> #include "lib/util/samba_util.h" #include "lib/util/debug.h" @@ -56,7 +57,7 @@ _PUBLIC_ uint64_t generate_unique_u64(uint64_t veto_value) int pid; } generate_unique_u64_state; - int pid = getpid(); + int pid = tevent_cached_getpid(); if (unlikely(pid != generate_unique_u64_state.pid)) { generate_unique_u64_state = (struct generate_unique_u64_state) { diff --git a/lib/util/util.c b/lib/util/util.c index 8c2a74fe5f3..02d1cbfda17 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -25,6 +25,7 @@ #include "replace.h" #include <talloc.h> +#include <tevent.h> #include "system/network.h" #include "system/filesys.h" #include "system/locale.h" @@ -422,7 +423,7 @@ _PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type) if ((ret != -1) && (lock.l_type != F_UNLCK) && (lock.l_pid != 0) && - (lock.l_pid != getpid())) { + (lock.l_pid != tevent_cached_getpid())) { DEBUG(3,("fcntl_lock: fd %d is locked by pid %d\n",fd,(int)lock.l_pid)); return true; } |