PATCH: remove all traces of java.io.FileDescriptor from java.net
Bryce McKinlay
bryce@waitaki.otago.ac.nz
Tue Mar 26 18:56:00 GMT 2002
Jeff Sturm wrote:
>Here's my updated patch. Hans convinced me that close/finalize ought to
>synchronize access to fnum, I've included that below.
>
Hmm, why is that? Also I noticed that it is actually synchronizing
twice, both in finalize and close?
Bryce.
>@@ -108,6 +103,22 @@ class PlainSocketImpl extends SocketImpl
> private native void write(byte[] buffer, int offset, int count)
> throws IOException;
>
>+ protected void finalize() throws Throwable
>+ {
>+ synchronized (this)
>+ {
>+ if (fnum != -1)
>+ try
>+ {
>+ close();
>+ }
>+ catch (IOException ex)
>+ {
>+ // ignore
>+ }
>+ }
>+ super.finalize();
>+ }
>
> /** @return the input stream attached to the socket.
> */
>
>@@ -413,6 +410,9 @@ java::net::PlainSocketImpl::accept (java
> void
> java::net::PlainSocketImpl::close()
> {
>+ // Avoid races from asynchronous finalization.
>+ JvSynchronize sync (this);
>+
> // should we use shutdown here? how would that effect so_linger?
> int res = ::close (fnum);
>
>
More information about the Java-patches
mailing list