avoid flock() under Solaris
This commit is contained in:
parent
31009166d7
commit
23777f291c
|
@ -321,7 +321,8 @@ advisory on other platforms.
|
||||||
|
|
||||||
Typically, locking is supported only for file ports, and attempting to
|
Typically, locking is supported only for file ports, and attempting to
|
||||||
acquire a lock with other kinds of file-stream ports raises an
|
acquire a lock with other kinds of file-stream ports raises an
|
||||||
@racket[exn:fail:filesystem] exception.}
|
@racket[exn:fail:filesystem] exception. Locking is not supported under Solaris,
|
||||||
|
where the @racket[exn:fail:unsupported] exception is raised.}
|
||||||
|
|
||||||
|
|
||||||
@defproc[(port-file-unlock [port file-stream-port?])
|
@defproc[(port-file-unlock [port file-stream-port?])
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
# define USE_FCNTL_O_NONBLOCK
|
# define USE_FCNTL_O_NONBLOCK
|
||||||
# define SOME_FDS_ARE_NOT_SELECTABLE
|
# define SOME_FDS_ARE_NOT_SELECTABLE
|
||||||
# define NEED_RESET_STDOUT_BLOCKING
|
# define NEED_RESET_STDOUT_BLOCKING
|
||||||
|
# undef USE_FLOCK_FOR_FILE_LOCKS
|
||||||
# define USE_TIMEZONE_AND_ALTZONE_VAR
|
# define USE_TIMEZONE_AND_ALTZONE_VAR
|
||||||
# define USE_NULL_TO_DISCONNECT_UDP
|
# define USE_NULL_TO_DISCONNECT_UDP
|
||||||
# else
|
# else
|
||||||
|
@ -1050,6 +1051,9 @@
|
||||||
pending bytes. Don't use this unless one of the HAS_<X>_IOB
|
pending bytes. Don't use this unless one of the HAS_<X>_IOB
|
||||||
flags is used. */
|
flags is used. */
|
||||||
|
|
||||||
|
/* USE_FLOCK_FOR_FILE_LOCKS means that flock() is available and works
|
||||||
|
for file locking. */
|
||||||
|
|
||||||
/* CLOSE_ALL_FDS_AFTER_FORK means that all fds except 0, 1, and 2
|
/* CLOSE_ALL_FDS_AFTER_FORK means that all fds except 0, 1, and 2
|
||||||
should be closed after performing a fork() for `process'
|
should be closed after performing a fork() for `process'
|
||||||
and `system' calls. */
|
and `system' calls. */
|
||||||
|
|
|
@ -4694,6 +4694,7 @@ scheme_file_buffer(int argc, Scheme_Object *argv[])
|
||||||
static int try_lock(int fd, int writer, int *_errid)
|
static int try_lock(int fd, int writer, int *_errid)
|
||||||
{
|
{
|
||||||
#ifdef UNIX_FILE_SYSTEM
|
#ifdef UNIX_FILE_SYSTEM
|
||||||
|
# ifdef USE_FLOCK_FOR_FILE_LOCKS
|
||||||
{
|
{
|
||||||
int ok;
|
int ok;
|
||||||
|
|
||||||
|
@ -4712,6 +4713,13 @@ static int try_lock(int fd, int writer, int *_errid)
|
||||||
*_errid = errno;
|
*_errid = errno;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
# else
|
||||||
|
/* using fcntl(F_SETFL, ...) isn't really an option, since the
|
||||||
|
any-close-release-the-lock semantics of fcntl()-based locks
|
||||||
|
doesn't work with Racket threads that compete for a lock */
|
||||||
|
*_errid = ENOTSUP;
|
||||||
|
return 0;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef WINDOWS_FILE_HANDLES
|
#ifdef WINDOWS_FILE_HANDLES
|
||||||
{
|
{
|
||||||
|
@ -4804,11 +4812,16 @@ Scheme_Object *scheme_file_unlock(int argc, Scheme_Object **argv)
|
||||||
check_already_closed("port-file-unlock", argv[0]);
|
check_already_closed("port-file-unlock", argv[0]);
|
||||||
|
|
||||||
#ifdef UNIX_FILE_SYSTEM
|
#ifdef UNIX_FILE_SYSTEM
|
||||||
|
# ifdef USE_FLOCK_FOR_FILE_LOCKS
|
||||||
do {
|
do {
|
||||||
ok = flock(fd, LOCK_UN);
|
ok = flock(fd, LOCK_UN);
|
||||||
} while ((ok == -1) && (errno == EINTR));
|
} while ((ok == -1) && (errno == EINTR));
|
||||||
ok = !ok;
|
ok = !ok;
|
||||||
errid = errno;
|
errid = errno;
|
||||||
|
# else
|
||||||
|
ok = 0;
|
||||||
|
errid = ENOTSUP;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef WINDOWS_FILE_HANDLES
|
#ifdef WINDOWS_FILE_HANDLES
|
||||||
ok = UnlockFile((HANDLE)fd, 0, 0, LOCK_ALL_FILE_LO, LOCK_ALL_FILE_HI);
|
ok = UnlockFile((HANDLE)fd, 0, 0, LOCK_ALL_FILE_LO, LOCK_ALL_FILE_HI);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#define HAS_STANDARD_IOB
|
#define HAS_STANDARD_IOB
|
||||||
#define FILES_HAVE_FDS
|
#define FILES_HAVE_FDS
|
||||||
#define USE_UNIX_SOCKETS_TCP
|
#define USE_UNIX_SOCKETS_TCP
|
||||||
|
#define USE_FLOCK_FOR_FILE_LOCKS
|
||||||
|
|
||||||
#define UNIX_PROCESSES
|
#define UNIX_PROCESSES
|
||||||
#define CLOSE_ALL_FDS_AFTER_FORK
|
#define CLOSE_ALL_FDS_AFTER_FORK
|
||||||
|
|
Loading…
Reference in New Issue
Block a user