Hi!
On 04/10/2014 07:39 PM, [email protected] wrote:
> Hi!
>> +static int sock_recv_poll(int fd, char *buf, int buf_size, int *offset)
>> +{
>> +    struct pollfd pfd;
>> +    pfd.fd = fd;
>> +    pfd.events = POLLIN;
>> +    int len = -1;
>> +    while (1) {
>> +            errno = 0;
>> +            int ret = poll(&pfd, 1, wait_timeout / 1000);
>> +            if (ret == -1) {
>> +                    if (errno == EINTR)
>> +                            continue;
>> +                    break;
>> +            }
>> +
>> +            if (ret == 0) {
>> +                    errno = ETIME;
>> +                    break;
>> +            }
>> +
>> +            if (ret != 1 || !(pfd.revents & POLLIN))
>> +                    break;
>> +
>> +            errno = 0;
>> +            len = recv(fd, buf + *offset,
>> +                    buf_size - *offset, MSG_DONTWAIT);
>> +
>> +            if (len == -1 && errno == EINTR)
>> +                    continue;
>> +            else
>> +                    break;
>> +    }
>> +
>> +    return len;
>> +}
> You pass the offset as a pointer but do not modify the value. Forgot to
> change it when the code around changed?

I think so. Also I could remove offset from this function and pass "buf" 
and "buf_size" to it with applied offset.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to