diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-02-27 23:08:37 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-02-27 23:08:37 +0100 |
commit | 5e70122b5481c878aa0773281304c4d68062cf7d (patch) | |
tree | 994ed029e1dad43fab6535092bf3a59966639c44 | |
parent | e2bcecad821f841ac40d0e0939f5805f8d142700 (diff) | |
download | fastd-5e70122b5481c878aa0773281304c4d68062cf7d.tar fastd-5e70122b5481c878aa0773281304c4d68062cf7d.zip |
Handle packet size correctly
-rw-r--r-- | src/fastd.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/fastd.c b/src/fastd.c index 0d4f1c1..b76216c 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -152,12 +152,12 @@ static void handle_tasks(fastd_context *ctx) { msg.msg_name = &sendaddr; msg.msg_namelen = sizeof(sendaddr); - struct iovec vec[2] = { + struct iovec iov[2] = { { .iov_base = &task->send.packet_type, .iov_len = 1 }, { .iov_base = task->send.buffer.base, .iov_len = task->send.buffer.len } }; - msg.msg_iov = vec; + msg.msg_iov = iov; msg.msg_iovlen = task->send.buffer.len ? 2 : 1; sendmsg(ctx->sockfd, &msg, 0); @@ -208,6 +208,7 @@ static void handle_input(fastd_context *ctx) { // TODO find correct peer + buffer.len = len; ctx->conf->method->method_send(ctx, ctx->peers, buffer); } if (fds[1].revents & POLLIN) { @@ -216,7 +217,7 @@ static void handle_input(fastd_context *ctx) { uint8_t packet_type; - struct iovec vec[2] = { + struct iovec iov[2] = { { .iov_base = &packet_type, .iov_len = 1 }, { .iov_base = buffer.base, .iov_len = max_len } }; @@ -227,7 +228,7 @@ static void handle_input(fastd_context *ctx) { msg.msg_name = &recvaddr; msg.msg_namelen = sizeof(recvaddr); - msg.msg_iov = vec; + msg.msg_iov = iov; msg.msg_iovlen = 2; ssize_t len = recvmsg(ctx->sockfd, &msg, 0); @@ -238,7 +239,7 @@ static void handle_input(fastd_context *ctx) { switch (packet_type) { case 0: - vec[1].iov_len = len - 1; + buffer.len = len - 1; ctx->conf->method->method_handle_recv(ctx, NULL, buffer); break; |