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;
}
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);