xfree(c);
}
+static int fix_up_socket(int fd, const char *what)
+{
+ int yes = 1;
+
+ if (fdflags(fd, O_NONBLOCK, O_NONBLOCK, 0, 0)) {
+ logmsg(0, LOG_ERR, "failed to set %s connection nonblocking: %s",
+ what, strerror(errno));
+ return (-1);
+ }
+
+ if (setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &yes, sizeof(yes))) {
+ logmsg(0, LOG_ERR,
+ "failed to disable `out-of-band' data on %s connection: %s",
+ what, strerror(errno));
+ return (-1);
+ }
+
+ return (0);
+}
+
static void done_client_write(int err, void *p)
{
struct client *c = p;
c->l->ao->name, strerror(errno));
goto err_0;
}
-
- if (fdflags(fd, O_NONBLOCK, O_NONBLOCK, 0, 0)) {
- logmsg(&c->q, LOG_ERR, "failed to set %s proxy socket nonblocking: %s",
- c->l->ao->name, strerror(errno));
- goto err_1;
- }
+ if (fix_up_socket(fd, "proxy")) goto err_1;
s = c->q.u.nat;
s.port = 113;
}
return;
}
+ if (fix_up_socket(sk, "incoming client")) { close(sk); return; }
c = xmalloc(sizeof(*c));
c->l = l;