Skip to content

Commit

Permalink
mcmc: upstream update for SO_KEEPALIVE
Browse files Browse the repository at this point in the history
  • Loading branch information
dormando committed Feb 16, 2022
1 parent 7e58c6d commit c985f2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vendor/mcmc/mcmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,15 @@ int mcmc_connect(void *c, char *host, char *port, int options) {
if (sock == -1)
continue;

// TODO: NONBLOCK
if (options & MCMC_OPTION_TCP_KEEPALIVE) {
int optval = 1;
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0) {
res = MCMC_ERR;
close(sock);
goto end;
}
}

if (options & MCMC_OPTION_NONBLOCK) {
int flags = fcntl(sock, F_GETFL);
if (flags < 0) {
Expand Down
1 change: 1 addition & 0 deletions vendor/mcmc/mcmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#define MCMC_OPTION_BLANK 0
#define MCMC_OPTION_NONBLOCK 1
#define MCMC_OPTION_TCP_KEEPALIVE (1<<1)

// convenience defines. if you want to save RAM you can set these smaller and
// error handler will only copy what you ask for.
Expand Down

0 comments on commit c985f2b

Please sign in to comment.