RFR: 8189366: SocketInputStream.available() should check for eof

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: 8189366: SocketInputStream.available() should check for eof

Vyom Tewari
Hi All,

Please review the simple change below.

Webrev   : http://cr.openjdk.java.net/~vtewari/8189366/webrev0.0/index.html

BugId      : https://bugs.openjdk.java.net/browse/JDK-8189366


Currently SocketInputStream.available() does not check for "eof" and
simply delegate to the impl even when "eof" reached. I put a check  to
return 0 if "eof" is already reached.

Thanks,

Vyom

Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8189366: SocketInputStream.available() should check for eof

Bernd Eckenfels-4
What is currently returned at the end of a stream? This looks like a dangerous thing to do, if a existing implementation only read when something is available it might never detect that it reached EOF.


From: net-dev <[hidden email]> on behalf of vyom tewari <[hidden email]>
Sent: Thursday, October 26, 2017 11:26:15 AM
To: OpenJDK Network Dev list
Subject: RFR: 8189366: SocketInputStream.available() should check for eof
 
Hi All,

Please review the simple change below.

Webrev   : http://cr.openjdk.java.net/~vtewari/8189366/webrev0.0/index.html

BugId      : https://bugs.openjdk.java.net/browse/JDK-8189366


Currently SocketInputStream.available() does not check for "eof" and
simply delegate to the impl even when "eof" reached. I put a check  to
return 0 if "eof" is already reached.

Thanks,

Vyom

Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8189366: SocketInputStream.available() should check for eof

Martin Buchholz-3
In reply to this post by Vyom Tewari
Any change that fiddles with "available" is never simple!

I confess to not understanding sockets, but intuitively they differ from files in that eof is a murky concept - there may not be any data from the other end of the socket right now, but who knows what's coming soon?  What's the difference between eof and closed?

Even for files eof might be murky - if some other process is writing to a file in append mode, eof might be a transient state.

On Thu, Oct 26, 2017 at 2:26 AM, vyom tewari <[hidden email]> wrote:
Hi All,

Please review the simple change below.

Webrev   : http://cr.openjdk.java.net/~vtewari/8189366/webrev0.0/index.html

BugId      : https://bugs.openjdk.java.net/browse/JDK-8189366


Currently SocketInputStream.available() does not check for "eof" and simply delegate to the impl even when "eof" reached. I put a check  to return 0 if "eof" is already reached.

Thanks,

Vyom


Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8189366: SocketInputStream.available() should check for eof

David Lloyd-2
In reply to this post by Bernd Eckenfels-4
On Thu, Oct 26, 2017 at 4:44 AM, Bernd Eckenfels <[hidden email]> wrote:
> What is currently returned at the end of a stream? This looks like a
> dangerous thing to do, if a existing implementation only read when something
> is available it might never detect that it reached EOF.

At present it ultimately delegates (on UNIXy) to ioctl(fd, FIONREAD,
xxx) which I guess will return an errno in this case.  If that's the
case then I agree that returning 0 is a smarter option.

--
- DML
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8189366: SocketInputStream.available() should check for eof

Vyom Tewari
In reply to this post by Bernd Eckenfels-4



On Thursday 26 October 2017 03:14 PM, Bernd Eckenfels wrote:
What is currently returned at the end of a stream? This looks like a dangerous thing to do, if a existing implementation only
Currently it returns 0 at end of stream and  same as after change. As David pointed out that ultimately it delegates on to "ioctl", i checked the doc(http://man7.org/linux/man-pages/man4/tty_ioctl.4.html) and did not found anything which tells about eof.

What i found out, setting eof at socketinputstream there is no effect on native  "ioctl" call. I set the "eof"  and SocketInputStream.available() return 0.

Let's wait for other people opinions.

Note: you have to shutdown the SocketInputstream to set "eof", i am not sure if there is any other way to set "eof" for SocketInputStream.

Thanks,
Vyom
 
read when something is available it might never detect that it reached EOF.


From: net-dev [hidden email] on behalf of vyom tewari [hidden email]
Sent: Thursday, October 26, 2017 11:26:15 AM
To: OpenJDK Network Dev list
Subject: RFR: 8189366: SocketInputStream.available() should check for eof
 
Hi All,

Please review the simple change below.

Webrev   : http://cr.openjdk.java.net/~vtewari/8189366/webrev0.0/index.html

BugId      : https://bugs.openjdk.java.net/browse/JDK-8189366


Currently SocketInputStream.available() does not check for "eof" and
simply delegate to the impl even when "eof" reached. I put a check  to
return 0 if "eof" is already reached.

Thanks,

Vyom