mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
flock --> fcntl
This commit is contained in:
parent
f4c222f986
commit
ee00b75441
@ -1,4 +1,4 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* pqcomm.c--
|
* pqcomm.c--
|
||||||
* Communication functions between the Frontend and the Backend
|
* Communication functions between the Frontend and the Backend
|
||||||
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.53 1998/09/01 04:28:51 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.54 1998/09/10 04:07:59 vadim Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -562,7 +562,11 @@ StreamServerPort(char *hostName, short portName, int *fdP)
|
|||||||
*/
|
*/
|
||||||
if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
|
if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
|
||||||
{
|
{
|
||||||
if (flock(lock_fd, LOCK_EX | LOCK_NB) == 0)
|
struct flock lck;
|
||||||
|
|
||||||
|
lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
|
||||||
|
lck.l_type = F_WRLCK;
|
||||||
|
if (fcntl(lock_fd, F_SETLK, &lck) == 0)
|
||||||
{
|
{
|
||||||
TPRINTF(TRACE_VERBOSE, "flock on %s, deleting", sock_path);
|
TPRINTF(TRACE_VERBOSE, "flock on %s, deleting", sock_path);
|
||||||
unlink(sock_path);
|
unlink(sock_path);
|
||||||
@ -607,7 +611,11 @@ StreamServerPort(char *hostName, short portName, int *fdP)
|
|||||||
*/
|
*/
|
||||||
if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
|
if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
|
||||||
{
|
{
|
||||||
if (flock(lock_fd, LOCK_EX | LOCK_NB) != 0)
|
struct flock lck;
|
||||||
|
|
||||||
|
lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
|
||||||
|
lck.l_type = F_WRLCK;
|
||||||
|
if (fcntl(lock_fd, F_SETLK, &lck) != 0)
|
||||||
TPRINTF(TRACE_VERBOSE, "flock error for %s", sock_path);
|
TPRINTF(TRACE_VERBOSE, "flock error for %s", sock_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -790,3 +798,5 @@ pq_putncharlen(char *s, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user