* 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
This commit is contained in:
parent
1b58660a9d
commit
47d0866c79
5 changed files with 73 additions and 31 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue