tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Cox PhD <b...@virtualschool.edu>
Subject RE: ServerSocket not being closed properly.
Date Tue, 24 Apr 2001 02:20:23 GMT
At 6:37 PM -0700 04/23/2001, Arun Katkere wrote:
>In my experience (having started/stopped Tomcat engine programatically via
>ContextManager API in a loop 100s of times), server socket is always closed
>correctly. And looking at 3.2.2 beta 3 source code, both PoolTcpEndpoint and
>SimpleTcpEndpoint close the server socket during shutdownEndpoint().

Could you provide sample code? Better yet, an explanation for the 
symptoms I provided? I'm inferring the cause but the symptoms are 
100% rock solid.

>BTW, doesn't your doStop() below kill the VM because there is a
>System.exit() in Ajp12ConnectionHandler shutdown?

It does kill the GUI, but System.exit() doesn't kill VisualAge. 
Hadnn't dug into this gui problem because the gui is useless after 
doStop anyway.

>ps: Each invocation leaves some threads running, which is bug 1418
>(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1418), resolved for 3.3
>(not 3.2.2). There is also some memory leak which I haven't had a chance to
>track down, yet.
>
>>  -----Original Message-----
>>  From: Brad Cox PhD [mailto:bcox@virtualschool.edu]
>>  Sent: Monday, April 23, 2001 6:04 PM
>>  To: tomcat-dev@jakarta.apache.org
>>  Subject: ServerSocket not being closed properly.
>>
>>
>>  At 7:06 PM -0500 04/23/2001, Marc Saegesser wrote:
>>  >I was just about to call the vote for the final release of
>>  Tomcat 3.2.2
>>  ...
>>
>>  While you're at it, could you ensure that tomcat closes its server
>>  socket  instead of relying on the system to do it when the VM exits?
>>  This is a long-standing problem that interferes with running tomcat
>>  inside  IBM's VisualAge, or (equivalently) building java GUIs for
>>  starting and stopping the server.
>>
>>  Here's what I've been using in a GUI for starting and stopping tomcat.
>>
>>  private void doStart(String[] args)
>>  {
>>	org.apache.tomcat.startup.Tomcat.main(args);
>>  }
>>  private void doStop()
>>  {
>>	String[] stopArgs = new String[] { "-stop" };
>>	org.apache.tomcat.startup.Tomcat.main(stopArgs);
>>  }
>>
>>  The buttons work the first time they're used. The start buttons fails
>>  the second times (either by the same GUI or by any other means during
>>  the same VisualAge session) because the server socket is still being
>>  held open by the lack of an explicit close. The only way I've found
>>  to clear the problem is to exit VisualAge altogether; a SLOOOWWWW
>>  process.
>>
>>  I've seen the same problem in my own applications. The fix was to be
>>  SURE that the ServerSocket is closed EXPLICITLY rather than leaving
>>  it to the operating system to do when the process exits.
>>
>>  This session console log may help locate the problem.
>>
>>  2001-04-24 08:51:00 - ContextManager: Adding context Ctx( /examples )
>>  2001-04-24 08:51:01 - ContextManager: Adding context Ctx( /admin )
>  > 2001-04-24 08:51:01 - Ctx( /svlt ): Set debug to 9
>  > 2001-04-24 08:51:01 - ContextManager: Adding context Ctx( /svlt )
>  > Starting tomcat. Check logs/tomcat.log for error messages
>>  2001-04-24 08:51:01 - ContextManager: Adding context Ctx(  )
>>  2001-04-24 08:51:01 - ContextManager: Adding context Ctx( /test )
>>  2001-04-24 08:51:01 - ContextManager: Adding context Ctx( /digiprop )
>>  2001-04-24 08:51:02 - Ctx( /svlt ): XmlReader - init  /svlt /digiprop
>>  2001-04-24 08:51:02 - Ctx( /svlt ): Reading /digiprop/WEB-INF/web.xml
>>  2001-04-24 08:51:02 - Ctx( /svlt ): Loading -2147483646 jsp
>>  2001-04-24 08:51:02 - Ctx( /svlt ): Loading 1 flush
>>  2001-04-24 08:51:03 - Ctx( /svlt ): Loading 1 page
>>  2001-04-24 08:51:03 - Ctx( /svlt ): Loading 1 login
>>  FATAL:java.net.SocketException: Address already in use
>>  java.net.SocketException: Address already in use
>>	java.lang.Throwable(java.lang.String)
>>	java.lang.Exception(java.lang.String)
>>	java.io.IOException(java.lang.String)
>>	java.net.SocketException(java.lang.String)
>>	void
>>  java.net.PlainSocketImpl.socketBind(java.net.InetAddress, int)
>>	void java.net.PlainSocketImpl.bind(java.net.InetAddress, int)
>>	java.net.ServerSocket(int, int, java.net.InetAddress)
>  >	java.net.ServerSocket(int, int)
>>	java.net.ServerSocket
>>  org.apache.tomcat.net.DefaultServerSocketFactory.createSocket(int,
>>  int)
>>	void org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint()
>>	void org.apache.tomcat.service.PoolTcpConnector.start()
>>	void org.apache.tomcat.core.ContextManager.start()
>>	void
>>  org.apache.tomcat.startup.Tomcat.execute(java.lang.String [])
>>	void org.apache.tomcat.startup.Tomcat.main(java.lang.String [])
>>  ---->	void digiprop.site.TomcatView.doStart()
>>	void
>>  digiprop.site.TomcatView.connEtoC2(java.awt.event.ActionEvent)
>>	void
>>  digiprop.site.TomcatView$IvjEventHandler.actionPerformed(java.
>awt.event.ActionEvent)
>>	void
>>  java.awt.Button.processActionEvent(java.awt.event.ActionEvent)
>>	void java.awt.Button.processEvent(java.awt.AWTEvent)
>>	void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
>>	void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
>>	void java.awt.EventDispatchThread.run()
>>
>>  --
>>  ---
>>  Brad Cox, Ph.D.; bcox@virtualschool.edu
>>  Phone: 703 361 4751 Cell: 703 919-9623
>>  http://virtualschool.edu
>>

-- 
---
Brad Cox, Ph.D.; bcox@virtualschool.edu
Phone: 703 361 4751 Cell: 703 919-9623
http://virtualschool.edu

Mime
View raw message