|
1 |
| - /*------------------------------------------------------------------------- |
| 1 | +/*------------------------------------------------------------------------- |
2 | 2 | *
|
3 | 3 | * pqcomm.c--
|
4 | 4 | * Communication functions between the Frontend and the Backend
|
|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * 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 $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -562,7 +562,11 @@ StreamServerPort(char *hostName, short portName, int *fdP)
|
562 | 562 | */
|
563 | 563 | if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
|
564 | 564 | {
|
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) |
566 | 570 | {
|
567 | 571 | TPRINTF(TRACE_VERBOSE, "flock on %s, deleting", sock_path);
|
568 | 572 | unlink(sock_path);
|
@@ -607,7 +611,11 @@ StreamServerPort(char *hostName, short portName, int *fdP)
|
607 | 611 | */
|
608 | 612 | if ((lock_fd = open(sock_path, O_RDONLY | O_NONBLOCK, 0666)) >= 0)
|
609 | 613 | {
|
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) |
611 | 619 | TPRINTF(TRACE_VERBOSE, "flock error for %s", sock_path);
|
612 | 620 | }
|
613 | 621 | }
|
@@ -790,3 +798,5 @@ pq_putncharlen(char *s, int n)
|
790 | 798 | }
|
791 | 799 |
|
792 | 800 | #endif
|
| 801 | + |
| 802 | + |
0 commit comments