summaryrefslogtreecommitdiff
path: root/minecproxy
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-07-04 12:01:46 +0200
committerDavid Härdeman <david@hardeman.nu>2020-07-04 12:01:46 +0200
commitbf24a9ac317f55ffa85df60ddffd171abc347e65 (patch)
tree718aa0155cbbe9de1f316aa663f0a73072350ff1 /minecproxy
parent43830ce2bff25a9acca4268ffaa3a681ac3afec2 (diff)
Fix splice implementation
Diffstat (limited to 'minecproxy')
-rw-r--r--minecproxy/server-proxy.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/minecproxy/server-proxy.c b/minecproxy/server-proxy.c
index b8a8988..814b1a9 100644
--- a/minecproxy/server-proxy.c
+++ b/minecproxy/server-proxy.c
@@ -135,9 +135,9 @@ void proxy_delete(struct server_proxy *proxy)
/*
* These four functions provide the fallback read-write mode
*/
-static void proxy_client_read(struct uring_task *task, int res);
+static void proxy_client_read_in(struct uring_task *task, int res);
-static void proxy_client_written(struct uring_task *task, int res)
+static void proxy_client_written_out(struct uring_task *task, int res)
{
struct server_proxy *proxy =
container_of(task, struct server_proxy, clienttask);
@@ -153,10 +153,10 @@ static void proxy_client_written(struct uring_task *task, int res)
proxy->client_bytes += res;
uring_task_set_fd(&proxy->clienttask, proxy->cfd);
- uring_tbuf_read(task, proxy_client_read);
+ uring_tbuf_read(task, proxy_client_read_in);
}
-static void proxy_client_read(struct uring_task *task, int res)
+static void proxy_client_read_in(struct uring_task *task, int res)
{
struct server_proxy *proxy =
container_of(task, struct server_proxy, clienttask);
@@ -171,12 +171,12 @@ static void proxy_client_read(struct uring_task *task, int res)
}
uring_task_set_fd(&proxy->clienttask, proxy->sfd);
- uring_tbuf_write(task, proxy_client_written);
+ uring_tbuf_write(task, proxy_client_written_out);
}
-static void proxy_server_read(struct uring_task *task, int res);
+static void proxy_server_read_in(struct uring_task *task, int res);
-static void proxy_server_written(struct uring_task *task, int res)
+static void proxy_server_written_out(struct uring_task *task, int res)
{
struct server_proxy *proxy =
container_of(task, struct server_proxy, servertask);
@@ -192,10 +192,10 @@ static void proxy_server_written(struct uring_task *task, int res)
proxy->server_bytes += res;
uring_task_set_fd(&proxy->servertask, proxy->sfd);
- uring_tbuf_read(&proxy->servertask, proxy_server_read);
+ uring_tbuf_read(&proxy->servertask, proxy_server_read_in);
}
-static void proxy_server_read(struct uring_task *task, int res)
+static void proxy_server_read_in(struct uring_task *task, int res)
{
struct server_proxy *proxy =
container_of(task, struct server_proxy, servertask);
@@ -210,7 +210,7 @@ static void proxy_server_read(struct uring_task *task, int res)
}
uring_task_set_fd(&proxy->servertask, proxy->cfd);
- uring_tbuf_write(task, proxy_server_written);
+ uring_tbuf_write(task, proxy_server_written_out);
}
/*
@@ -221,7 +221,7 @@ static void proxy_client_spliced_in(struct uring_task *task, int res);
static void proxy_client_spliced_out(struct uring_task *task, int res)
{
struct server_proxy *proxy =
- container_of(task, struct server_proxy, servertask);
+ container_of(task, struct server_proxy, clienttask);
assert_return(task);
assert_task_alive(DBG_PROXY, task);
@@ -232,6 +232,7 @@ static void proxy_client_spliced_out(struct uring_task *task, int res)
return;
}
+ proxy->client_bytes += res;
uring_splice(task, proxy->cfd, proxy->cpipe[PIPE_WR],
proxy_client_spliced_in);
}
@@ -239,7 +240,7 @@ static void proxy_client_spliced_out(struct uring_task *task, int res)
static void proxy_client_spliced_in(struct uring_task *task, int res)
{
struct server_proxy *proxy =
- container_of(task, struct server_proxy, servertask);
+ container_of(task, struct server_proxy, clienttask);
assert_return(task);
assert_task_alive(DBG_PROXY, task);
@@ -270,6 +271,7 @@ static void proxy_server_spliced_out(struct uring_task *task, int res)
return;
}
+ proxy->server_bytes += res;
uring_splice(task, proxy->sfd, proxy->spipe[PIPE_WR],
proxy_server_spliced_in);
}
@@ -326,8 +328,8 @@ static void proxy_connected_cb(struct connection *conn, bool connected)
proxy->spipe[PIPE_WR], proxy_server_spliced_in);
} else {
debug(DBG_PROXY, "handling proxy connection with read-write");
- uring_tbuf_read(&proxy->clienttask, proxy_client_read);
- uring_tbuf_read(&proxy->servertask, proxy_server_read);
+ uring_tbuf_read(&proxy->clienttask, proxy_client_read_in);
+ uring_tbuf_read(&proxy->servertask, proxy_server_read_in);
}
}