summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c5
-rw-r--r--main.c3
-rw-r--r--proxy.c7
-rw-r--r--proxy.h2
-rw-r--r--uring.c3
5 files changed, 17 insertions, 3 deletions
diff --git a/config.c b/config.c
index f13191b..e5d4cc7 100644
--- a/config.c
+++ b/config.c
@@ -75,6 +75,7 @@ strtosockaddrs(const char *str, struct list_head *list)
if (*str == '[') {
/* IPv6, [a:b:c...h]:p or [*]:p */
+ fprintf(stderr, "Attempting to parse an IPv6 addr\n");
str++;
tmp = strchr(str, ']');
if (!tmp)
@@ -105,6 +106,7 @@ strtosockaddrs(const char *str, struct list_head *list)
} else if (*str == '*') {
/* IPv4, *:p */
+ fprintf(stderr, "Attempting to parse an IPv4 wildcard\n");
str++;
if (*str != ':')
goto out;
@@ -204,6 +206,7 @@ strtosockaddrs(const char *str, struct list_head *list)
} else if (strtou16_strict(tmp, &port) == 0) {
/* Port */
+ fprintf(stderr, "Attempting to parse a port\n");
addr = zmalloc(sizeof(*addr));
if (!addr)
goto out;
@@ -221,6 +224,8 @@ strtosockaddrs(const char *str, struct list_head *list)
addr->in4.sin_port = htons(port);
addr->addrlen = sizeof(addr->in4);
list_add(&addr->list, list);
+ } else {
+ goto out;
}
success:
diff --git a/main.c b/main.c
index f9df355..2385bf8 100644
--- a/main.c
+++ b/main.c
@@ -250,6 +250,9 @@ signalfd_init(struct cfg *cfg)
sigaction(SIGHUP, &action, NULL);
sigaction(SIGTERM, &action, NULL);
+ action.sa_handler = SIG_IGN;
+ sigaction(SIGPIPE, &action, NULL);
+
sfd = eventfd(0, EFD_CLOEXEC);
if (sfd < 0)
perrordie("eventfd");
diff --git a/proxy.c b/proxy.c
index 28760e4..e5a4eff 100644
--- a/proxy.c
+++ b/proxy.c
@@ -51,6 +51,7 @@ proxy_client_data_out(struct cfg *cfg, struct uring_task *task, int res)
return;
}
+ uring_task_set_fd(&proxy->clienttask, proxy->cfd);
uring_read(cfg, task, proxy->clientbuf, sizeof(proxy->clientbuf), 0, proxy_client_data_in);
}
@@ -64,6 +65,7 @@ proxy_client_data_in(struct cfg *cfg, struct uring_task *task, int res)
return;
proxy->clientlen = res;
+ uring_task_set_fd(&proxy->clienttask, proxy->sfd);
uring_write(cfg, task, proxy->clientbuf, res, proxy_client_data_out);
}
@@ -83,6 +85,7 @@ proxy_server_data_out(struct cfg *cfg, struct uring_task *task, int res)
return;
}
+ uring_task_set_fd(&proxy->servertask, proxy->sfd);
uring_read(cfg, task, proxy->serverbuf, sizeof(proxy->serverbuf), 0, proxy_server_data_in);
}
@@ -96,6 +99,7 @@ proxy_server_data_in(struct cfg *cfg, struct uring_task *task, int res)
return;
proxy->serverlen = res;
+ uring_task_set_fd(&proxy->servertask, proxy->cfd);
uring_write(cfg, task, proxy->serverbuf, res, proxy_server_data_out);
}
@@ -152,6 +156,7 @@ again:
goto again;
}
+ proxy->sfd = sfd;
uring_task_set_fd(&proxy->servertask, sfd);
uring_connect(cfg, &proxy->servertask, &proxy->server, proxy_server_connected);
}
@@ -167,6 +172,8 @@ proxy_new(struct cfg *cfg, struct server *scfg, struct sockaddr_in46 *client, in
return NULL;
}
+ proxy->sfd = -1;
+ proxy->cfd = fd;
proxy->scfg = scfg;
proxy->client = *client;
sockaddr_to_str(&proxy->client, proxy->clientstr, sizeof(proxy->clientstr));
diff --git a/proxy.h b/proxy.h
index 4d68a5d..e580d80 100644
--- a/proxy.h
+++ b/proxy.h
@@ -7,12 +7,14 @@ struct server_proxy {
char clientbuf[4096];
size_t clientlen;
struct uring_task clienttask;
+ int cfd;
struct sockaddr_in46 server;
char serverstr[ADDRSTRLEN];
char serverbuf[4096];
size_t serverlen;
struct uring_task servertask;
+ int sfd;
unsigned next_remote;
struct server *scfg;
diff --git a/uring.c b/uring.c
index 96e3a67..770b8c5 100644
--- a/uring.c
+++ b/uring.c
@@ -88,9 +88,6 @@ uring_task_get(struct cfg *cfg, struct uring_task *task)
void
uring_task_set_fd(struct uring_task *task, int fd)
{
- if (task->fd >= 0)
- error("Leaking fd %i\n", task->fd);
-
task->fd = fd;
}