mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
lib/util: use RUNNING_ON_VALGRIND to check if valgrind is used
We should not skip all of close_low_fd() just because we detected valgrind headers at build time. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
This commit is contained in:
parent
be5e4d164d
commit
bfb1494e81
@ -21,11 +21,22 @@
|
||||
#include "system/filesys.h"
|
||||
#include "close_low_fd.h"
|
||||
|
||||
#ifdef HAVE_VALGRIND_VALGRIND_H
|
||||
#include <valgrind/valgrind.h>
|
||||
#elif defined(HAVE_VALGRIND_H)
|
||||
#include <valgrind.h>
|
||||
#else
|
||||
#define RUNNING_ON_VALGRIND 0
|
||||
#endif
|
||||
|
||||
_PUBLIC_ int close_low_fd(int fd)
|
||||
{
|
||||
#ifndef VALGRIND
|
||||
int ret, dev_null;
|
||||
|
||||
if (RUNNING_ON_VALGRIND) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev_null = open("/dev/null", O_RDWR, 0);
|
||||
|
||||
if ((dev_null == -1) && (errno == ENFILE)) {
|
||||
@ -60,6 +71,5 @@ _PUBLIC_ int close_low_fd(int fd)
|
||||
return err;
|
||||
}
|
||||
close(dev_null);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user