RFR 8203369 : Check for both EAGAIN and EWOULDBLOCK error codes

Ivan Gerasimov ivan.gerasimov at oracle.com
Fri May 25 05:49:18 UTC 2018


Hi Wiijun!


On 5/24/18 10:13 PM, Weijun Wang wrote:
>
>> On May 25, 2018, at 11:58 AM, Ivan Gerasimov <ivan.gerasimov at oracle.com> wrote:
>>
>>> I also wonder whether a smart compiler might not flag code where the errors do infact have the same value:
>>>
>>> if (errno == 11 || errno == 11) ...
>>>
>> At least gcc -O completely removes the second redundant test, so no observable changes is expected on supported platforms.
> And it silently compiles without showing any warning, right? Good if yes.
>
> --Max

Yep, all is good.
I've built/tested the patched JDK on all supported platforms with no issues.

And we already have places, where both EAGAIN and EWOULDBLOCK are used 
in one if clause (as I just replied to David):
java.base/unix/native/libnet/SocketInputStream.c, in NET_ReadWithTimeout():
         result = NET_NonBlockingRead(fd, bufP, len);
         if (result == -1 && ((errno == EAGAIN) || (errno == 
EWOULDBLOCK))) {


So the fix basically proposes to use this approach consistently.


With kind regards,
Ivan

-- 
With kind regards,
Ivan Gerasimov



More information about the net-dev mailing list