Skip to content

Commit 58bb75b

Browse files
committed
Restore accept4(SOCK_NONBLOCK) on OpenBSD
1 parent d40f055 commit 58bb75b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

thinproxy.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,11 @@ accept_conn(int lfd)
15281528
struct conn *c;
15291529

15301530
sl = sizeof(ss);
1531+
#ifdef __OpenBSD__
1532+
fd = accept4(lfd, (struct sockaddr *)&ss, &sl, SOCK_NONBLOCK);
1533+
#else
15311534
fd = accept(lfd, (struct sockaddr *)&ss, &sl);
1535+
#endif
15321536
if (fd == -1) {
15331537
if (errno == EMFILE || errno == ENFILE) {
15341538
logmsg(LOG_ERR, "accept: %s", strerror(errno));
@@ -1560,10 +1564,12 @@ accept_conn(int lfd)
15601564
return;
15611565
}
15621566

1567+
#ifndef __OpenBSD__
15631568
if (set_nonblock(fd) == -1) {
15641569
close(fd);
15651570
return;
15661571
}
1572+
#endif
15671573

15681574
on = 1;
15691575
(void)setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));

0 commit comments

Comments
 (0)