qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 2/3] NBD library: add aio-compatible read/write


From: Stefan Hajnoczi
Subject: [Qemu-devel] Re: [PATCH 2/3] NBD library: add aio-compatible read/write function
Date: Mon, 21 Feb 2011 20:10:17 +0000

On Mon, Feb 21, 2011 at 12:37 PM, Kevin Wolf <address@hidden> wrote:
> Am 18.02.2011 13:55, schrieb Nick Thomas:
>> +retry:
>> +    if (do_read) {
>> +        ret = recvmsg(sockfd, &msg, 0);
>> +    } else {
>> +        ret = sendmsg(sockfd, &msg, 0);
>> +    }
>> +
>> +    /* recoverable error */
>> +    if (ret == -1 && (errno == EAGAIN || errno == EINTR)) {
>> +        goto retry;
>> +    }
>
> Make this a do...while loop, no reason for goto here.

This is not asynchronous.

If we're writing and the in-kernel socket buffer is full then we'll spin
retrying - this burns CPU for no reason.  Instead we should get a
callback when the socket becomes writable again so we can fill it with
more data.

If we're reading and enough data hasn't arrived yet we will spin
retrying.  Again, we should set up a callback to be notified when the
socket becomes readable again.

It seems sheepdog suffers from the same problem.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]