Okay, that's the last one.  The incubator repo should now be fully up-to-date
with respect to the svn.facebook.com repo.  Still working on Git, but it should
be done by tonight.

--David

[EMAIL PROTECTED] wrote:
> Author: dreiss
> Date: Tue Jun 10 18:20:54 2008
> New Revision: 666502
> 
> URL: http://svn.apache.org/viewvc?rev=666502&view=rev
> <http://svn.apache.org/viewvc?rev=666502&view=rev>
> Log:
> Java/TThreadPoolServer: Shut down more gracefully.  (THRIFT-11)
> 
> Modified:
>    
> incubator/thrift/trunk/lib/java/src/com/facebook/thrift/server/TThreadPoolServer.java
> 
> Modified:
> incubator/thrift/trunk/lib/java/src/com/facebook/thrift/server/TThreadPoolServer.java
> URL:
> http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/java/src/com/facebook/thrift/server/TThreadPoolServer.java?rev=666502&r1=666501&r2=666502&view=diff
> <http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/java/src/com/facebook/thrift/server/TThreadPoolServer.java?rev=666502&r1=666501&r2=666502&view=diff>
> ==============================================================================
> ---
> incubator/thrift/trunk/lib/java/src/com/facebook/thrift/server/TThreadPoolServer.java
> (original)
> +++
> incubator/thrift/trunk/lib/java/src/com/facebook/thrift/server/TThreadPoolServer.java
> Tue Jun 10 18:20:54 2008
> @@ -176,11 +176,22 @@
>      }
> 
>      executorService_.shutdown();
> -    try {
> -      executorService_.awaitTermination(options_.stopTimeoutVal,
> -                                        options_.stopTimeoutUnit);
> -    } catch (InterruptedException ix) {
> -      // Ignore and more on
> +
> +    // Loop until awaitTermination finally does return without a
> interrupted
> +    // exception. If we don't do this, then we'll shut down
> prematurely. We want
> +    // to let the executorService clear it's task queue, closing client
> sockets
> +    // appropriately.
> +    long timeoutMS =
> options_.stopTimeoutUnit.toMillis(options_.stopTimeoutVal);
> +    long now = System.currentTimeMillis();
> +    while (timeoutMS >= 0) {
> +      try {
> +        executorService_.awaitTermination(timeoutMS,
> TimeUnit.MILLISECONDS);
> +        break;
> +      } catch (InterruptedException ix) {
> +        long newnow = System.currentTimeMillis();
> +        timeoutMS -= (newnow - now);
> +        now = newnow;
> +      }
>      }
>    }
> 
> @@ -220,7 +231,9 @@
>          outputTransport = outputTransportFactory_.getTransport(client_);
>          inputProtocol = inputProtocolFactory_.getProtocol(inputTransport);
>          outputProtocol =
> outputProtocolFactory_.getProtocol(outputTransport);
> -        while (processor.process(inputProtocol, outputProtocol)) {}
> +        // we check stopped_ first to make sure we're not supposed to
> be shutting
> +        // down. this is necessary for graceful shutdown.
> +        while (!stopped_ && processor.process(inputProtocol,
> outputProtocol)) {}
>        } catch (TTransportException ttx) {
>          // Assume the client died and continue silently
>        } catch (TException tx) {
> 
> 

Reply via email to