From 346da6565477a492a4308508914c0e9a009e2608 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 27 Mar 2022 23:16:48 -0700 Subject: [PATCH] ... --- src/net/wait.c | 13 ++++++------- test/unit/net.tests.c | 1 - 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/net/wait.c b/src/net/wait.c index c500393..beb4af3 100644 --- a/src/net/wait.c +++ b/src/net/wait.c @@ -17,21 +17,20 @@ int net_wait(int sock, struct peer *info, void *buf, size_t buf_size) { i = recv(sock,p,size,0); if(-1==i) { - if(!((errno==EAGAIN)||(errno==EWOULDBLOCK))) { - perror("recv"); - return -1; - } + if((errno==EAGAIN)||(errno==EWOULDBLOCK)) { return 0; } + perror("recv"); + return -1; } - if((i!=size)&&(size>0)) { goto cached; } + if(i!=size) { goto cached; } return 1; cached: if(net_cache( &(info->in), /* void **prev */ &(info->in_size), /* size_t *prev_size */ - p, /* void *p */ - i /* size_t size */ + buf, /* void *p */ + buf_size - size + i /* size_t size */ )<0) { return -1; } return 0; } diff --git a/test/unit/net.tests.c b/test/unit/net.tests.c index 748983c..0fabe6d 100644 --- a/test/unit/net.tests.c +++ b/test/unit/net.tests.c @@ -132,7 +132,6 @@ static void net_wait_basic_test() { assert(1==net_wait(read_sock,info,buf,100)); assert(info->in==NULL); - assert(info->in_size==0); assert(memcmp(buf,expected,100)==0); close(read_sock); -- 2.39.5