On Mon, Feb 21, 2011 at 12:37 PM, Kevin Wolf <kw...@redhat.com> 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