aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/main.c b/main.c
index 21cc727..3618105 100644
--- a/main.c
+++ b/main.c
@@ -51,7 +51,14 @@ void *client_loop(void *ign) {
while (1) {
char data[512];
pthread_mutex_unlock(&send_lock); // TODO: proper locking, this works for now but is certainly inefficient
- uint64_t new_len = read(client_fd, data, 512);
+ uint64_t new_len;
+ {
+ ssize_t len = read(client_fd, data, 512);
+ if (len < 0)
+ new_len = 0;
+ else
+ new_len = len;
+ }
pthread_mutex_lock(&send_lock);
if (new_len == 0) {