aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/net/natPlainSocketImpl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/net/natPlainSocketImpl.cc')
-rw-r--r--libjava/java/net/natPlainSocketImpl.cc8
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);