bebcb6453c54164564b24899c6f407310b551a93 max Thu Jan 5 06:37:34 2023 -0800 first go at s3:// support, refs #30445 adding cache file to UDC protocol support, refs #30445 handling expired presigned URLs in udc protocol, refs #30445 diff --git src/lib/obscure.c src/lib/obscure.c index 0694097..6431f5f 100644 --- src/lib/obscure.c +++ src/lib/obscure.c @@ -1,22 +1,23 @@ /* Obscure stuff that is handy every now and again. * * This file is copyright 2002 Jim Kent, but license is hereby * granted for all use - public, private or commercial. */ #include "common.h" #include <unistd.h> +#include <sys/syscall.h> #include "portable.h" #include "localmem.h" #include "hash.h" #include "obscure.h" #include "linefile.h" #include "sqlNum.h" static int _dotForUserMod = 100; /* How often does dotForUser() output a dot. */ long incCounterFile(char *fileName) /* Increment a 32 bit value on disk. */ { long val = 0; FILE *f = fopen(fileName, "r+b"); if (f != NULL) @@ -1033,16 +1034,31 @@ } boolean readAndIgnore(char *fileName) /* Read a byte from fileName, so its access time is updated. */ { boolean ret = FALSE; char buf[256]; FILE *f = fopen(fileName, "r"); if ( f && (fread(buf, 1, 1, f) == 1 ) ) ret = TRUE; if (f) fclose(f); return ret; } - +int get_thread_id() { +/* return some int specific to a thread, copied from https://stackoverflow.com/questions/21091000/how-to-get-thread-id-of-a-pthread-in-linux-c-program */ +#if defined(__linux__) + return syscall(SYS_gettid); +#elif defined(__FreeBSD__) + long tid; + thr_self(&tid); + return (int)tid; +#elif defined(__NetBSD__) + return _lwp_self(); +#elif defined(__OpenBSD__) + return getthrid(); +#else + return getpid(); +#endif +}