[kaffe] synchronization patch for PlainDatagramSocketImpl
jrandom
jrandom at i2p.net
Tue Jun 28 09:05:14 PDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi y'all,
I'm adding support for a high degree transport to i2p and noticed
that kaffe's PlainDatagramSocketImpl synchronizes all the native
methods, in addition to explicit locks on the receive(...) and
send(...) queues. This obviously b0rks anything that tries to
use a single socket to send and receive from (one thread blocking
on .receive, and other threads occationally calling .send), so I've
made the attached patch removing the native object scoped
synchronization, resolving the issue (firing up -vmdebug NATIVENET
showed no problems either). While I personally don't explicitly
need all of the native calls to be unsynchronized (just the send0
and receive0 calls), I thought it'd make sense to remove it across
the board (unless someone out there knows why it needs to be?)
(if it matters, yes, sun's jvm works fine with a thread blocking
on receive(...) and other threads calling send(...))
hth,
=jr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCwYGLWYfZ3rPnHH0RAqqxAJ9aWqq8cGpspI9xnZiPVqIUgnIgagCfb/BC
VwXGmdCipJjvKzHOsuuznNs=
=giai
-----END PGP SIGNATURE-----
-------------- next part --------------
Index: PlainDatagramSocketImpl.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/gnu/java/net/PlainDatagramSocketImpl.java,v
retrieving revision 1.4
diff -u -r1.4 PlainDatagramSocketImpl.java
--- PlainDatagramSocketImpl.java 7 Jan 2005 18:40:25 -0000 1.4
+++ PlainDatagramSocketImpl.java 28 Jun 2005 16:01:57 -0000
@@ -155,23 +155,23 @@
}
}
-protected synchronized native int peekData(DatagramPacket p) throws IOException;
-protected synchronized native void bind(int lport, InetAddress laddr) throws SocketException;
-protected synchronized native void send0(DatagramPacket p) throws IOException;
-protected synchronized native int peek(InetAddress i) throws IOException;
-protected synchronized native void receive0(DatagramPacket p) throws IOException;
-protected synchronized native void setTTL(byte ttl) throws IOException;
-protected synchronized native byte getTTL() throws IOException;
-protected synchronized native void join(InetAddress inetaddr) throws IOException;
-protected synchronized native void leave(InetAddress inetaddr) throws IOException;
-protected synchronized native void joinGroup(SocketAddress inetaddr,
- NetworkInterface netIf) throws IOException;
-protected synchronized native void leaveGroup(SocketAddress inetaddr,
- NetworkInterface netIf) throws IOException;
-protected synchronized native void socketSetOption(int option, Object value);
-protected synchronized native int socketGetOption(int option);
-private synchronized native void datagramSocketCreate();
-private synchronized native void datagramSocketClose();
-protected synchronized native void setBlocking(boolean block);
+protected native int peekData(DatagramPacket p) throws IOException;
+protected native void bind(int lport, InetAddress laddr) throws SocketException;
+protected native void send0(DatagramPacket p) throws IOException;
+protected native int peek(InetAddress i) throws IOException;
+protected native void receive0(DatagramPacket p) throws IOException;
+protected native void setTTL(byte ttl) throws IOException;
+protected native byte getTTL() throws IOException;
+protected native void join(InetAddress inetaddr) throws IOException;
+protected native void leave(InetAddress inetaddr) throws IOException;
+protected native void joinGroup(SocketAddress inetaddr,
+ NetworkInterface netIf) throws IOException;
+protected native void leaveGroup(SocketAddress inetaddr,
+ NetworkInterface netIf) throws IOException;
+protected native void socketSetOption(int option, Object value);
+protected native int socketGetOption(int option);
+private native void datagramSocketCreate();
+private native void datagramSocketClose();
+protected native void setBlocking(boolean block);
}
More information about the kaffe
mailing list