This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: gnu.java.net: Making methods in socket impl synchronized


Hi list,



I wrote a little patch to make some methods in gnu.java.net.PlainSocketImpl 
and gnu.java.net.PlainDatagramSocketImpl synchroized. I have no real opinion 
if this is really needed but the classpath version does it and I think I is 
good.

Please review and comment.



Michael
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2359
diff -u -b -B -r1.2359 ChangeLog
--- ChangeLog	25 Nov 2003 18:26:07 -0000	1.2359
+++ ChangeLog	25 Nov 2003 19:01:19 -0000
@@ -1,5 +1,19 @@
 2003-11-25  Michael Koch  <konqueror@gmx.de>
 
+	* gnu/java/net/PlainDatagramSocketImpl.java
+	(bind): Made synchronized.
+	(create): Likewise.
+	(setOption): Likewise.
+	(getOption): Likewise.
+	(close): Likewise.
+	(getTTL): Likewise.
+	(setTTL): Likewise.
+	* gnu/java/net/PlainSocketImpl.java
+	(bind): Made synchronized.
+	(create): Likewise.
+
+2003-11-25  Michael Koch  <konqueror@gmx.de>
+
 	* gcj/javaprims.h: Added missing java.util.Currency.
 
 2003-11-25  Michael Koch  <konqueror@gmx.de>
Index: gnu/java/net/PlainDatagramSocketImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/PlainDatagramSocketImpl.java,v
retrieving revision 1.3
diff -u -b -B -r1.3 PlainDatagramSocketImpl.java
--- gnu/java/net/PlainDatagramSocketImpl.java	21 Oct 2003 12:29:43 -0000	1.3
+++ gnu/java/net/PlainDatagramSocketImpl.java	25 Nov 2003 19:01:19 -0000
@@ -135,7 +135,7 @@
    *
    * @exception SocketException If an error occurs
    */
-  protected native void bind(int lport, InetAddress laddr)
+  protected native synchronized void bind(int port, InetAddress addr)
 	throws SocketException;
 
   protected native void connect (InetAddress i, int port)
@@ -148,7 +148,7 @@
    *
    * @exception SocketException If an error occurs
    */
-  protected native void create() throws SocketException;
+  protected native synchronized void create() throws SocketException;
   
   protected native int peek(InetAddress i) throws IOException;
   
@@ -198,7 +198,8 @@
    *
    * @exception SocketException If an error occurs
    */
-  public native void setOption(int optID, Object value) throws SocketException;
+  public native synchronized void setOption(int option_id, Object val)
+    throws SocketException;
 
   /**
    * Retrieves the value of an option on the socket
@@ -209,7 +210,8 @@
    *
    * @exception SocketException If an error occurs
    */
-  public native Object getOption(int optID) throws SocketException;
+  public native synchronized Object getOption(int option_id)
+    throws SocketException;
   
   private native void mcastGrp(InetAddress inetaddr, NetworkInterface netIf,
 		               boolean join) throws IOException;
@@ -217,7 +219,7 @@
   /**
    * Closes the socket
    */
-  protected native void close();
+  protected native synchronized void close();
 
   /**
    * Gets the Time to Live value for the socket
@@ -228,7 +230,7 @@
    *
    * @deprecated 1.2
    */
-  protected byte getTTL() throws IOException
+  protected synchronized byte getTTL() throws IOException
   {
     return (byte) getTimeToLive();
   }
@@ -242,7 +244,7 @@
    *
    * @deprecated 1.2
    */
-  protected void setTTL(byte ttl) throws IOException
+  protected synchronized void setTTL(byte ttl) throws IOException
   {
     setTimeToLive(((int) ttl) & 0xFF);
   }
Index: gnu/java/net/PlainSocketImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/PlainSocketImpl.java,v
retrieving revision 1.4
diff -u -b -B -r1.4 PlainSocketImpl.java
--- gnu/java/net/PlainSocketImpl.java	21 Oct 2003 12:29:43 -0000	1.4
+++ gnu/java/net/PlainSocketImpl.java	25 Nov 2003 19:01:19 -0000
@@ -185,7 +185,8 @@
    *
    * @param stream true for a stream socket, false for a datagram socket
    */
-  protected native void create (boolean stream)  throws IOException;
+  protected native synchronized void create(boolean stream)
+    throws IOException;
 
   /**
    * Connects to the remote hostname and port specified as arguments.
@@ -225,7 +226,8 @@
    *
    * @exception IOException If an error occurs
    */
-  protected native void bind (InetAddress host, int port) throws IOException;
+  protected native synchronized void bind(InetAddress addr, int port)
+    throws IOException;
 
   /**
    * Starts listening for connections on a socket. The queuelen parameter

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]