Article View: net.sources.games
Article #755ATC for System V: A Quick Fix
From: DJ Molny
Date: Mon, 12 Jan 1987 19:09
Date: Mon, 12 Jan 1987 19:09
91 lines
2836 bytes
2836 bytes
The ATC source I posted on Friday assumed that kernel file locking
was available. While this is true of System V Release 2 systems
from AT&T, it is not included in all versions of System V.
To get around the problem, I've introduced another compile option in
the top level Makefile. If you have /usr/group standard record and
file locking (check for the presence of /usr/include/unistd.h),
leave the makefile as is. Otherwise, comment out the line that
says "UNISTD = -DUNISTD".
The new locking scheme is based on exclusive creation of a
temporary file. It's hardly bullet-proof, but it should suffice
in a friendly environment. Anybody who wants to beef it up
should feel free to do so.
Five files are affected by this change: Makefile, src/Makefile,
src/include.h, src/log.c, and src/graphics.c. Vanilla diff's appear
below. Sorry for the inconvenience.
Diff for Makefile:
14a15,17
> # for System V with kernel locking, use the following line
> UNISTD = -DUNISTD
>
47,49c50,52
< ( cd $(SRC); \
< make OSVER=$(OSVER) DEST='"$(DESTINATION)"' \
< $(CURSESLIBR) USETERML=$(USETERML) )
---
> (cd $(SRC); \
> make OSVER=$(OSVER) UNISTD=$(UNISTD) \
> DEST='"$(DESTINATION)"' $(CURSESLIBR) USETERML=$(USETERML) )
Diff for src/Makefile:
10c10
< CFLAGS = -O -D$(OSVER) -DDEST='$(DEST)'
---
> CFLAGS = $(UNISTD) -O -D$(OSVER) -DDEST='$(DEST)'
Diff for src/include.h:
24a25
> #ifdef UNISTD
25a27
> #endif
27a30
> #include <errno.h>
Diff for src/log.c:
82a83
> #ifdef UNISTD
83a85,100
> #else
> #define LOCKNAME "/tmp/atc.lock"
> /* locking scheme for those without kernel file locking */
> for (i=0; i < 10; i++)
> {
> if (open(LOCKNAME, O_WRONLY|O_CREAT|O_EXCL, 0200) != -1)
> break; /* success */
> if (errno != EEXIST) /* some other error */
> {
> i = 10;
> break;
> }
> sleep(2);
> }
>
> if (i == 10) /* hit loop end, bomb out */
84a102
> #endif
190c208,210
< /* lock will evaporate upon close */
---
> /* kernel lock will evaporate upon close */
> #ifndef UNISTD
> unlink(LOCKNAME); /* remove lock file */
Diffs for src/graphics.c:
11,13d10
< #ifdef SYSV
< #include <errno.h>
< #endif
--
Regards,
DJ Molny, N9609U
ihnp4!cuae2!djmolny
Technical Details
Message-ID:
<7253@cuae2.ATT.COM>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!columbia!rutgers!clyde!burl!codas!cuae2!djmolnyShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!columbia!rutgers!clyde!burl!codas!cuae2!djmolny From: djmolny@cuae2.ATT.COM (DJ Molny) Newsgroups: net.sources.games Subject: ATC for System V: A Quick Fix Message-ID: <7253@cuae2.ATT.COM> Date: Mon, 12-Jan-87 14:09:56 EST Article-I.D.: cuae2.7253 Posted: Mon Jan 12 14:09:56 1987 Date-Received: Tue, 13-Jan-87 06:37:27 EST Sender: usenet@cuae2.ATT.COM Organization: AT&T - /app/eng, Lisle, IL Lines: 91 Keywords: locking