Skip to content

Commit

Permalink
Removed dlsym dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed May 26, 2023
1 parent b9789a4 commit 7bb8ba6
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,31 +286,8 @@ static ssize_t uv__fs_mkdtemp(uv_fs_t* req) {
}


static int (*uv__mkostemp)(char*, int);


static void uv__mkostemp_initonce(void) {
/* z/os doesn't have RTLD_DEFAULT but that's okay
* because it doesn't have mkostemp(O_CLOEXEC) either.
*/
#ifdef RTLD_DEFAULT
uv__mkostemp = (int (*)(char*, int)) dlsym(RTLD_DEFAULT, "mkostemp");

/* We don't care about errors, but we do want to clean them up.
* If there has been no error, then dlerror() will just return
* NULL.
*/
dlerror();
#endif /* RTLD_DEFAULT */
}


static int uv__fs_mkstemp(uv_fs_t* req) {
static uv_once_t once = UV_ONCE_INIT;
int r;
#ifdef O_CLOEXEC
static _Atomic int no_cloexec_support;
#endif
static const char pattern[] = "XXXXXX";
static const size_t pattern_size = sizeof(pattern) - 1;
char* path;
Expand All @@ -331,27 +308,6 @@ static int uv__fs_mkstemp(uv_fs_t* req) {
goto clobber;
}

uv_once(&once, uv__mkostemp_initonce);

#ifdef O_CLOEXEC
if (atomic_load_explicit(&no_cloexec_support, memory_order_relaxed) == 0 &&
uv__mkostemp != NULL) {
r = uv__mkostemp(path, O_CLOEXEC);

if (r >= 0)
return r;

/* If mkostemp() returns EINVAL, it means the kernel doesn't
support O_CLOEXEC, so we just fallback to mkstemp() below. */
if (errno != EINVAL)
goto clobber;

/* We set the static variable so that next calls don't even
try to use mkostemp. */
atomic_store_explicit(&no_cloexec_support, 1, memory_order_relaxed);
}
#endif /* O_CLOEXEC */

if (req->cb != NULL)
uv_rwlock_rdlock(&req->loop->cloexec_lock);

Expand Down

0 comments on commit 7bb8ba6

Please sign in to comment.