freebsd-ports/www/xitami/files/patch-ac
Steve Price 2ca9383e73 Update to version 2.4d7.
PR:		25222
Submitted by:	Bernd Luevelsmeyer <bdluevel@heitec.net>
2001-02-26 05:00:12 +00:00

39 lines
1.7 KiB
Text

--- src/sfl/.vimbk/sflproc.c.vimbk Sat Apr 1 18:11:24 2000
+++ src/sfl/sflproc.c Tue Nov 7 11:29:34 2000
@@ -1711,8 +1711,6 @@
file_handle;
char
pid_buffer [10];
- struct flock
- lock_file; /* flock() argument block */
#endif
int
argi = 0, /* Input arguments iterator */
@@ -1787,17 +1785,21 @@
if (lockfile && strused (lockfile))
{
- file_handle = open (lockfile, O_RDWR | O_CREAT, 0640);
- if (file_handle < 0)
+ if ((file_handle = (open (lockfile, O_RDONLY | O_CREAT, 0640))) == -1)
return (-1); /* We could not open lock file */
- else
+ if (flock(file_handle, LOCK_EX | LOCK_NB) == -1 && errno == EWOULDBLOCK)
{
- lock_file.l_type = F_WRLCK;
- if (fcntl (file_handle, F_SETLK, &lock_file))
- return (-1); /* We could not obtain a lock */
+ close (file_handle);
+ return (-1); /* The file is already locked */
}
+ close (file_handle);
+
+ if ((file_handle = (open (lockfile, O_RDWR | O_TRUNC, 0640))) == -1)
+ return (-1); /* We could not open lock file */
+ if (flock(file_handle, LOCK_EX | LOCK_NB) == -1)
+ return (-1); /* We could not obtain a lock */
/* We record the server's process id in the lock file */
- sprintf (pid_buffer, "%6d\n", getpid ());
+ sprintf (pid_buffer, "%ld\n", (long)getpid ());
write (file_handle, pid_buffer, strlen (pid_buffer));
}