aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1998-10-06 02:31:42 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1998-10-06 02:31:42 +0000
commit9e23ab9b5c62ff048584ba3e5de646eff5017fca (patch)
tree4175c983968b5339825f1a83c49bf066059cfcab /src/backend
parent16c6545d5644354da1c7764f710d4de98e754df2 (diff)
downloadpostgresql-9e23ab9b5c62ff048584ba3e5de646eff5017fca.tar.gz
postgresql-9e23ab9b5c62ff048584ba3e5de646eff5017fca.zip
Add configure test to make sure fcntl(SETLK) is available,
and make backend/libpq/pqcomm.c only try to lock the socket file when the call exists. Also, change open-RDONLY to open-WRONLY; at least on my platform, you can't get a write lock on a file you didn't open for writing.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/libpq/pqcomm.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index cab6289d9e0..74f14516e59 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.54 1998/09/10 04:07:59 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.55 1998/10/06 02:31:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -560,7 +560,8 @@ StreamServerPort(char *hostName, short portName, int *fdP)
* If the socket exists but nobody has an advisory lock on it we
* can safely delete the file.
*/
- if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
+#ifdef HAVE_FCNTL_SETLK
+ if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK, 0666)) >= 0)
{
struct flock lck;
@@ -575,6 +576,7 @@ StreamServerPort(char *hostName, short portName, int *fdP)
TPRINTF(TRACE_VERBOSE, "flock failed for %s", sock_path);
close(lock_fd);
}
+#endif /* HAVE_FCNTL_SETLK */
}
else
{
@@ -609,7 +611,8 @@ StreamServerPort(char *hostName, short portName, int *fdP)
* Open the socket file and get an advisory lock on it. The
* lock_fd is left open to keep the lock.
*/
- if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
+#ifdef HAVE_FCNTL_SETLK
+ if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK, 0666)) >= 0)
{
struct flock lck;
@@ -618,6 +621,7 @@ StreamServerPort(char *hostName, short portName, int *fdP)
if (fcntl(lock_fd, F_SETLK, &lck) != 0)
TPRINTF(TRACE_VERBOSE, "flock error for %s", sock_path);
}
+#endif /* HAVE_FCNTL_SETLK */
}
listen(fd, SOMAXCONN);