From: alex Date: Mon, 28 Mar 2022 06:16:48 +0000 (-0700) Subject: ... X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=346da6565477a492a4308508914c0e9a009e2608;p=seeder ... --- 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);