diff options
author | Jeff Sturm <jsturm@one-point.com> | 2002-03-28 02:08:36 +0000 |
---|---|---|
committer | Jeff Sturm <jsturm@gcc.gnu.org> | 2002-03-28 02:08:36 +0000 |
commit | 47d0866c79c04d8d86ce3d1eff9dda7899179c4b (patch) | |
tree | 51916c05d0f82e2a643314cf640e5e7582d021d9 /libjava/java/net/natPlainSocketImpl.cc | |
parent | 1b58660a9d302afe516eca5023066585ae6ceb85 (diff) | |
download | gcc-47d0866c79c04d8d86ce3d1eff9dda7899179c4b.zip gcc-47d0866c79c04d8d86ce3d1eff9dda7899179c4b.tar.gz gcc-47d0866c79c04d8d86ce3d1eff9dda7899179c4b.tar.bz2 |
* java/net/PlainDatagramSocketImpl.java
(close): Use native implementation.
(finalize): New method.
* java/net/PlainSocketImpl.java (finalize): New method.
* java/net/natPlainDatagramSocketImpl.cc
(java/io/FileDescriptor.h): Don't include.
(close): Implement method here.
(create): Don't assign fd.
* java/net/natPlainSocketImpl.cc
(java/io/FileDescriptor.h): Don't include.
(create): Don't assign fd.
(accept): Likewise.
(close): Synchronize.
From-SVN: r51492
Diffstat (limited to 'libjava/java/net/natPlainSocketImpl.cc')
-rw-r--r-- | libjava/java/net/natPlainSocketImpl.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libjava/java/net/natPlainSocketImpl.cc b/libjava/java/net/natPlainSocketImpl.cc index 3afc5d5..85f8313 100644 --- a/libjava/java/net/natPlainSocketImpl.cc +++ b/libjava/java/net/natPlainSocketImpl.cc @@ -102,7 +102,6 @@ _Jv_accept (int fd, struct sockaddr *addr, socklen_t *addrlen) #include <gcj/cni.h> #include <gcj/javaprims.h> #include <java/io/IOException.h> -#include <java/io/FileDescriptor.h> #include <java/io/InterruptedIOException.h> #include <java/net/BindException.h> #include <java/net/ConnectException.h> @@ -234,8 +233,9 @@ java::net::PlainSocketImpl::create (jboolean stream) _Jv_platform_close_on_exec (sock); + // We use fnum in place of fd here. From leaving fd null we avoid + // the double close problem in FileDescriptor.finalize. fnum = sock; - fd = new java::io::FileDescriptor (sock); } void @@ -402,7 +402,6 @@ java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s) s->localport = localport; s->address = new InetAddress (raddr, NULL); s->port = rport; - s->fd = new java::io::FileDescriptor (new_socket); return; error: char* strerr = strerror (errno); @@ -413,6 +412,9 @@ java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s) 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); |