]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/util: make use of tevent_cached_getpid() in performance critical code
authorStefan Metzmacher <metze@samba.org>
Mon, 25 Jul 2022 12:29:35 +0000 (14:29 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 25 Jul 2022 17:34:33 +0000 (17:34 +0000)
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>
lib/util/genrand_util.c
lib/util/util.c

index 9aa35de3ae7d69dd8dbd888aba6a7f143ae3d44c..fdc2654a20443e9d339d137465bc64fa3603a35d 100644 (file)
@@ -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) {
index 8c2a74fe5f348331a0971f10666db845f421d923..02d1cbfda17f46d2d645a0ac481cd141be495eb9 100644 (file)
@@ -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;
                }