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;
c->l->ao->socket_to_sockaddr(&s, &ss, &ssz);
selbuf_disable(&c->b);
+ c->px = px; px->c = c;
+ px->fd = -1;
if (conn_init(&px->cn, &sel, fd, (struct sockaddr *)&ss, ssz,
proxy_connected, px)) {
logmsg(&c->q, LOG_ERR, "failed to make %s proxy connection to %s: %s",
goto err_2;
}
- c->px = px; px->c = c;
- px->fd = -1;
return;
err_2:
}
return;
}
+ if (fix_up_socket(sk, "incoming client")) { close(sk); return; }
c = xmalloc(sizeof(*c));
c->l = l;