2004-03-17 Michael Koch <konqueror@gmx.de>
* gnu/java/net/PlainDatagramSocketImpl.java (RECEIVE_LOCK): New member field. (SEND_LOCK): New member field. (send0): New method. (send): Synchronize on SEND_LOCK. (receive0): New method. (receive): Synchronize on RECEIVE_LOCK. * gnu/java/net/natPlainDatagramSocketImplNoNet.cc, gnu/java/net/natPlainDatagramSocketImplPosix.cc, gnu/java/net/natPlainDatagramSocketImplWin32.cc (send0): Renamed from send. (receive0): Renamed from receive. From-SVN: r79579
This commit is contained in:
parent
aa18fb30ad
commit
3e368284ac
4 changed files with 36 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
/* PlainDatagramSocketImpl.java -- Default DatagramSocket implementation
|
||||
Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2001, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -60,8 +60,8 @@ import gnu.classpath.Configuration;
|
|||
* It makes native calls to C routines that implement BSD style
|
||||
* SOCK_DGRAM sockets in the AF_INET family.
|
||||
*
|
||||
* @author Aaron M. Renn <arenn@urbanophile.com>
|
||||
* @author Warren Levy <warrenl@cygnus.com>
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
* @author Warren Levy (warrenl@cygnus.com)
|
||||
*/
|
||||
public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
{
|
||||
|
@ -95,6 +95,16 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
* This is the actual underlying file descriptor
|
||||
*/
|
||||
int native_fd = -1;
|
||||
|
||||
/**
|
||||
* Lock object to serialize threads wanting to receive
|
||||
*/
|
||||
private final Object RECEIVE_LOCK = new Object();
|
||||
|
||||
/**
|
||||
* Lock object to serialize threads wanting to send
|
||||
*/
|
||||
private final Object SEND_LOCK = new Object();
|
||||
|
||||
// FIXME: Is this necessary? Could it help w/ DatagramSocket.getLocalAddress?
|
||||
// InetAddress address;
|
||||
|
@ -179,7 +189,7 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*
|
||||
* @exception IOException If an error occurs
|
||||
*/
|
||||
protected native void send(DatagramPacket p) throws IOException;
|
||||
protected native void send(DatagramPacket packet) throws IOException;
|
||||
|
||||
/**
|
||||
* Receives a UDP packet from the network
|
||||
|
|
|
@ -286,6 +286,8 @@ gnu::java::net::PlainDatagramSocketImpl::close ()
|
|||
void
|
||||
gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *p)
|
||||
{
|
||||
JvSynchronize lock (SEND_LOCK);
|
||||
|
||||
// FIXME: Deal with Multicast and if the socket is connected.
|
||||
jint rport = p->getPort();
|
||||
union SockAddr u;
|
||||
|
@ -327,6 +329,8 @@ gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *p)
|
|||
void
|
||||
gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *p)
|
||||
{
|
||||
JvSynchronize lock (RECEIVE_LOCK);
|
||||
|
||||
// FIXME: Deal with Multicast and if the socket is connected.
|
||||
union SockAddr u;
|
||||
socklen_t addrlen = sizeof(u);
|
||||
|
|
|
@ -273,6 +273,8 @@ gnu::java::net::PlainDatagramSocketImpl::close ()
|
|||
void
|
||||
gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *p)
|
||||
{
|
||||
JvSynchronize lock (SEND_LOCK);
|
||||
|
||||
// FIXME: Deal with Multicast and if the socket is connected.
|
||||
jint rport = p->getPort();
|
||||
union SockAddr u;
|
||||
|
@ -313,6 +315,8 @@ gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *p)
|
|||
void
|
||||
gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *p)
|
||||
{
|
||||
JvSynchronize lock (RECEIVE_LOCK);
|
||||
|
||||
// FIXME: Deal with Multicast and if the socket is connected.
|
||||
union SockAddr u;
|
||||
socklen_t addrlen = sizeof(u);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue