Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ee00b75

Browse files
committed
flock --> fcntl
1 parent f4c222f commit ee00b75

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/backend/libpq/pqcomm.c

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*-------------------------------------------------------------------------
1+
/*-------------------------------------------------------------------------
22
*
33
* pqcomm.c--
44
* Communication functions between the Frontend and the Backend
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.53 1998/09/01 04:28:51 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.54 1998/09/10 04:07:59 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -562,7 +562,11 @@ StreamServerPort(char *hostName, short portName, int *fdP)
562562
*/
563563
if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
564564
{
565-
if (flock(lock_fd, LOCK_EX | LOCK_NB) == 0)
565+
struct flock lck;
566+
567+
lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
568+
lck.l_type = F_WRLCK;
569+
if (fcntl(lock_fd, F_SETLK, &lck) == 0)
566570
{
567571
TPRINTF(TRACE_VERBOSE, "flock on %s, deleting", sock_path);
568572
unlink(sock_path);
@@ -607,7 +611,11 @@ StreamServerPort(char *hostName, short portName, int *fdP)
607611
*/
608612
if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
609613
{
610-
if (flock(lock_fd, LOCK_EX | LOCK_NB) != 0)
614+
struct flock lck;
615+
616+
lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
617+
lck.l_type = F_WRLCK;
618+
if (fcntl(lock_fd, F_SETLK, &lck) != 0)
611619
TPRINTF(TRACE_VERBOSE, "flock error for %s", sock_path);
612620
}
613621
}
@@ -790,3 +798,5 @@ pq_putncharlen(char *s, int n)
790798
}
791799

792800
#endif
801+
802+

0 commit comments

Comments
 (0)