Re: Problems with poll()/write() on non-blocking sockets
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:x-mailer :mime-version:subject:date:references; bh=lo4QCVxsMrKYynKSYJrS2uUfZ+7Oya1ZHimQ+ttn4S8=; b=dior4TMvxDXefq3klDm6nzByv1C/FnJHJRxwqSRc4uQq6rkX6Yl+QT+Z+HSvnab3zH 00AoOwJIvNAEgRKtca+Q5azAIT978leNlq7Jwu5U0EQas2+MP61Czw0PAb7tigSDlMMP eHwgU39ib5evz5mwnG/32fs/nzDppgwP65F5g= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:x-mailer:mime-version:subject:date :references; b=RKxhBYxDg1SVPrYWGSO+W6BM55PxTlsrGYJ/HPsxdEepg4BcYLYsUg3TfBO5D3kt44 I34tlMPVvFYWaYkUOqNK2vT7UXOy9vkZKFnl9zyLFQHuWD6sJI41vLJ3lj/B8lLegllj njnhuLxiJBF8LBZodzCH14+KEqbREtPG6Xxkc= (reforwarding to list since original bounced) Sent from my iPhone On May 26, 2010, at 9:41 AM, Eric Ogren <eogren@gmail.com> wrote: Eric Sent from my iPhone Hello everyone, Thanks a lot, Jakub _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/eogren%40riverbed.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Hi Jakub - you may want to investigate the snd_lowat socket option. The Darwin implementation of poll() ignores this option so it may report a socket writable even when the actual write() call will fail. setting the lowat to 1 fixed this issue for me. On May 26, 2010, at 9:11 AM, "Jakub Bednar" <jakub.bednar@avg.com> wrote: during stress testing of my network application I have found some strange behavior of Mac OS X sockets. I have a communication thread, that calls a poll() checking whether data can be written to a non-blocking socket. Upon exit from this function I check for POLLERR or POLLHUP and then perform a write() to the socket. If the write returns -1 and errno is set to EINTR or EAGAIN, I go back to poll. Otherwise I close the socket as there was an error. This works great most of the time, but during stress testing I found out a strange behavior (e.g. after 8 hours of video streaming). The poll() unblocks the socket and call to write () returns -1 with errno EAGAIN immediately. I go back to poll() and the same happens again leading to busy loop. I found one post telling that it is correct for poll() to unblock a socket and that the socket can become non-writable before I manage to call write(), but this is happing all the time for my socket and never recovers. Should I consider EAGAIN to be an error and close the connection? Wouldn't this cause another problems? I can't see another way out of this issue and I don't even understand why this is happening. I'm not asking for nor handling OUT-OF-BAND data flags in poll() but I don't think it could cause the problem. Another thing is, that Shark's System Trace keeps telling me that the syscall write returned 0x0 and not -1. Maybe a bug in C library? Can anyone please help me out of this or explain why is this happening? This email sent to eogren@riverbed.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Eric Ogren