unix USE_FCNTL vs 'perm'
Reported directly to devteam, the POSIX_TYPES subset (most? all these days?) of Unix that defines USE_FCNTL was unlocking lock file 'perm' when done with it but wasn't explicitly closing it unless the unlocking failed. Triggered a valgrind complaint and could have posed a problem if restart gets implemented for this configuraiton.
This commit is contained in:
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.161 $ $NHDT-Date: 1573063606 2019/11/06 18:06:46 $
|
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.162 $ $NHDT-Date: 1573066356 2019/11/06 18:52:36 $
|
||||||
|
|
||||||
This fixes36.3 file is here to capture information about updates in the 3.6.x
|
This fixes36.3 file is here to capture information about updates in the 3.6.x
|
||||||
lineage following the release of 3.6.2 in May 2019. Please note, however,
|
lineage following the release of 3.6.2 in May 2019. Please note, however,
|
||||||
@@ -269,6 +269,7 @@ EDIT_GETLIN: using 'O' to set message types or menu colors was overloading the
|
|||||||
during repeat prompting
|
during repeat prompting
|
||||||
EDIT_GETLIN: for paranoid confirmation, if answer was neither "yes" nor "no",
|
EDIT_GETLIN: for paranoid confirmation, if answer was neither "yes" nor "no",
|
||||||
don't supply the rejected answer as the default when retrying
|
don't supply the rejected answer as the default when retrying
|
||||||
|
USE_FCNTL: nethack wasn't closing lock file 'perm'
|
||||||
curses: very tall menus tried to use selector characters a-z, A-Z, and 0-9,
|
curses: very tall menus tried to use selector characters a-z, A-Z, and 0-9,
|
||||||
but 0-9 should be reserved for counts and if the display was tall
|
but 0-9 should be reserved for counts and if the display was tall
|
||||||
enough for more than 62 entries, arbitrary ASCII punctuation got used
|
enough for more than 62 entries, arbitrary ASCII punctuation got used
|
||||||
|
|||||||
+8
-7
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 files.c $NHDT-Date: 1571347976 2019/10/17 21:32:56 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.254 $ */
|
/* NetHack 3.6 files.c $NHDT-Date: 1573066357 2019/11/06 18:52:37 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.260 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -1644,7 +1644,7 @@ boolean uncomp;
|
|||||||
static int nesting = 0;
|
static int nesting = 0;
|
||||||
|
|
||||||
#if defined(NO_FILE_LINKS) || defined(USE_FCNTL) /* implies UNIX */
|
#if defined(NO_FILE_LINKS) || defined(USE_FCNTL) /* implies UNIX */
|
||||||
static int lockfd; /* for lock_file() to pass to unlock_file() */
|
static int lockfd = -1; /* for lock_file() to pass to unlock_file() */
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_FCNTL
|
#ifdef USE_FCNTL
|
||||||
struct flock sflock; /* for unlocking, same as above */
|
struct flock sflock; /* for unlocking, same as above */
|
||||||
@@ -1756,7 +1756,7 @@ int retryct;
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
register int errnosv = errno;
|
int errnosv = errno;
|
||||||
|
|
||||||
switch (errnosv) { /* George Barbanis */
|
switch (errnosv) { /* George Barbanis */
|
||||||
case EEXIST:
|
case EEXIST:
|
||||||
@@ -1867,9 +1867,10 @@ const char *filename;
|
|||||||
if (nesting == 1) {
|
if (nesting == 1) {
|
||||||
#ifdef USE_FCNTL
|
#ifdef USE_FCNTL
|
||||||
sflock.l_type = F_UNLCK;
|
sflock.l_type = F_UNLCK;
|
||||||
if (fcntl(lockfd, F_SETLK, &sflock) == -1) {
|
if (lockfd >= 0) {
|
||||||
HUP raw_printf("Can't remove fcntl lock on %s.", filename);
|
if (fcntl(lockfd, F_SETLK, &sflock) == -1)
|
||||||
(void) close(lockfd);
|
HUP raw_printf("Can't remove fcntl lock on %s.", filename);
|
||||||
|
(void) close(lockfd), lockfd = -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
lockname = make_lockname(filename, locknambuf);
|
lockname = make_lockname(filename, locknambuf);
|
||||||
@@ -1881,7 +1882,7 @@ const char *filename;
|
|||||||
if (unlink(lockname) < 0)
|
if (unlink(lockname) < 0)
|
||||||
HUP raw_printf("Can't unlink %s.", lockname);
|
HUP raw_printf("Can't unlink %s.", lockname);
|
||||||
#ifdef NO_FILE_LINKS
|
#ifdef NO_FILE_LINKS
|
||||||
(void) nhclose(lockfd);
|
(void) nhclose(lockfd), lockfd = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* UNIX || VMS */
|
#endif /* UNIX || VMS */
|
||||||
|
|||||||
Reference in New Issue
Block a user