1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-27 23:54:45 +00:00

Use SOCK_CLOEXEC correctly.

This commit is contained in:
Calvin Rose 2020-05-07 07:55:08 -05:00
parent 79c3139748
commit 084fc9776d

View File

@ -494,7 +494,7 @@ static Janet cfun_net_connect(int32_t argc, Janet *argv) {
struct addrinfo *ai = janet_get_addrinfo(argv, 0); struct addrinfo *ai = janet_get_addrinfo(argv, 0);
/* Create socket */ /* Create socket */
JSock sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol | JSOCKFLAGS); JSock sock = socket(ai->ai_family, ai->ai_socktype | JSOCKFLAGS, ai->ai_protocol);
if (!JSOCKVALID(sock)) { if (!JSOCKVALID(sock)) {
freeaddrinfo(ai); freeaddrinfo(ai);
janet_panic("could not create socket"); janet_panic("could not create socket");
@ -525,7 +525,7 @@ static Janet cfun_net_server(int32_t argc, Janet *argv) {
JSock sfd = JSOCKDEFAULT; JSock sfd = JSOCKDEFAULT;
struct addrinfo *rp = NULL; struct addrinfo *rp = NULL;
for (rp = ai; rp != NULL; rp = rp->ai_next) { for (rp = ai; rp != NULL; rp = rp->ai_next) {
sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol | JSOCKFLAGS); sfd = socket(rp->ai_family, rp->ai_socktype | JSOCKFLAGS, rp->ai_protocol);
if (!JSOCKVALID(sfd)) continue; if (!JSOCKVALID(sfd)) continue;
/* Set various socket options */ /* Set various socket options */
int enable = 1; int enable = 1;