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

Commit 2355da8

Browse files
committed
more portable way to switch socket to nonblock mode
1 parent 9527db9 commit 2355da8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arbiter.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <errno.h>
1717
#include <netdb.h>
1818
#include <time.h>
19+
#include <fcntl.h>
1920

2021
#include "postgres.h"
2122
#include "fmgr.h"
@@ -380,10 +381,11 @@ static int MtmConnectSocket(char const* host, int port, int max_attempts)
380381
while (1) {
381382
int rc = -1;
382383

383-
sd = socket(AF_INET, SOCK_STREAM|SOCK_NONBLOCK, 0);
384+
sd = socket(AF_INET, SOCK_STREAM, 0);
384385
if (sd < 0) {
385386
elog(ERROR, "Arbiter failed to create socket: %d", errno);
386387
}
388+
fcntl(sd, F_SETFL, O_NONBLOCK);
387389
busy_socket = sd;
388390
for (i = 0; i < n_addrs; ++i) {
389391
memcpy(&sock_inet.sin_addr, &addrs[i], sizeof sock_inet.sin_addr);

0 commit comments

Comments
 (0)