mmanders 01/08/22 09:56:28
Modified: src/share/org/apache/tomcat/startup StopTomcat.java
Log:
Added code to handle shutdown a little cleaner by flushing the output stream and
wait for one second before trying to close the stream. This gives the backend a
chance to read the stream cleanly before it goes away.
Revision Changes Path
1.11 +18 -0
jakarta-tomcat/src/share/org/apache/tomcat/startup/StopTomcat.java
Index: StopTomcat.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/StopTomcat.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- StopTomcat.java 2001/08/21 05:35:26 1.10
+++ StopTomcat.java 2001/08/22 16:56:28 1.11
@@ -244,6 +244,15 @@
Socket socket = new Socket(address, portInt);
OutputStream os=socket.getOutputStream();
sendAjp12Stop( os, secret );
+
+ // Setting soLinger to 0 will help make sure the connection is
+ // closed on NetWare. If the other side closes the connection
+ // first, we get a SocketException so catch and ignore it
+ try {
+ socket.setSoLinger(true, 0);
+ }
+ catch (java.net.SocketException ignore) {
+ }
os.flush();
os.close();
// socket.close();
@@ -264,6 +273,15 @@
os.write( stopMessage );
if(secret!=null )
sendAjp12String( os, secret );
+
+ // flush the stream and give the backend a chance to read the request
+ // and shut down before we close the socket
+ os.flush();
+ try {
+ Thread.sleep(1000);
+ }
+ catch (InterruptedException ignore) {
+ }
}
/** Small AJP12 client util