You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2001/08/29 03:44:07 UTC
cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http HttpConnector.java
remm 01/08/28 18:44:07
Modified: catalina/src/share/org/apache/catalina/connector/http
HttpConnector.java
Log:
- Fix race conditions during HTTP connector shutdown.
Patch submitted by Michael Newman <newman at mindless.com>
Revision Changes Path
1.23 +53 -52 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java
Index: HttpConnector.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- HttpConnector.java 2001/08/23 22:32:10 1.22
+++ HttpConnector.java 2001/08/29 01:44:07 1.23
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v 1.22 2001/08/23 22:32:10 craigmcc Exp $
- * $Revision: 1.22 $
- * $Date: 2001/08/23 22:32:10 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v 1.23 2001/08/29 01:44:07 remm Exp $
+ * $Revision: 1.23 $
+ * $Date: 2001/08/29 01:44:07 $
*
* ====================================================================
*
@@ -96,7 +96,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.22 $ $Date: 2001/08/23 22:32:10 $
+ * @version $Revision: 1.23 $ $Date: 2001/08/29 01:44:07 $
*/
@@ -108,6 +108,12 @@
/**
+ * The <code>Service</code> we are associated with (if any).
+ */
+ private Service service = null;
+
+
+ /**
* The accept count for this Connector.
*/
private int acceptCount = 10;
@@ -252,12 +258,6 @@
/**
- * The <code>Service</code> we are associated with (if any).
- */
- private Service service = null;
-
-
- /**
* The string manager for this package.
*/
private StringManager sm =
@@ -316,6 +316,28 @@
/**
+ * Return the <code>Service</code> with which we are associated (if any).
+ */
+ public Service getService() {
+
+ return (this.service);
+
+ }
+
+
+ /**
+ * Set the <code>Service</code> with which we are associated (if any).
+ *
+ * @param service The service that owns this Engine
+ */
+ public void setService(Service service) {
+
+ this.service = service;
+
+ }
+
+
+ /**
* Return the connection timeout for this Connector.
*/
public int getConnectionTimeout() {
@@ -733,28 +755,6 @@
/**
- * Return the <code>Service</code> with which we are associated (if any).
- */
- public Service getService() {
-
- return (this.service);
-
- }
-
-
- /**
- * Set the <code>Service</code> with which we are associated (if any).
- *
- * @param service The service that owns this Engine
- */
- public void setService(Service service) {
-
- this.service = service;
-
- }
-
-
- /**
* Return the TCP no delay flag value.
*/
public boolean getTcpNoDelay() {
@@ -982,16 +982,18 @@
} catch (IOException e) {
// if (debug >= 3)
// log("run: Accept returned IOException", e);
- if (started && !stopped)
- log("accept: ", e);
try {
- // if (debug >= 3)
- // log("run: Closing server socket");
- serverSocket.close();
- if (!stopped) {
- // if (debug >= 3)
- // log("run: Reopening server socket");
- serverSocket = open();
+ synchronized (threadSync) {
+ if (started && !stopped)
+ log("accept: ", e);
+ if (!stopped) {
+ // if (debug >= 3)
+ // log("run: Closing server socket");
+ serverSocket.close();
+ // if (debug >= 3)
+ // log("run: Reopening server socket");
+ serverSocket = open();
+ }
}
// if (debug >= 3)
// log("run: IOException processing completed");
@@ -1054,12 +1056,10 @@
log(sm.getString("httpConnector.stopping"));
stopped = true;
- synchronized (threadSync) {
- try {
- threadSync.wait(5000);
- } catch (InterruptedException e) {
- ;
- }
+ try {
+ threadSync.wait(5000);
+ } catch (InterruptedException e) {
+ ;
}
thread = null;
@@ -1168,17 +1168,18 @@
}
}
- // Close the server socket we were using
- if (serverSocket != null) {
- try {
- serverSocket.close();
- } catch (IOException e) {
- ;
+ synchronized (threadSync) {
+ // Close the server socket we were using
+ if (serverSocket != null) {
+ try {
+ serverSocket.close();
+ } catch (IOException e) {
+ ;
+ }
}
+ // Stop our background thread
+ threadStop();
}
-
- // Stop our background thread
- threadStop();
serverSocket = null;
}