diff --git a/lib/rb/lib/thrift/server/tserver.rb b/lib/rb/lib/thrift/server/tserver.rb
index <HASH>..<HASH> 100644
--- a/lib/rb/lib/thrift/server/tserver.rb
+++ b/lib/rb/lib/thrift/server/tserver.rb
@@ -32,23 +32,26 @@ class TSimpleServer < TServer
   end
 
   def serve()
-    @serverTransport.listen()
-    while (true)
-      client = @serverTransport.accept()
-      trans = @transportFactory.getTransport(client)
-      prot = @protocolFactory.getProtocol(trans)
-      begin
-        while (true)
-          @processor.process(prot, prot)
+    begin
+      @serverTransport.listen()
+      while (true)
+        client = @serverTransport.accept()
+        trans = @transportFactory.getTransport(client)
+        prot = @protocolFactory.getProtocol(trans)
+        begin
+          while (true)
+            @processor.process(prot, prot)
+          end
+        rescue TTransportException, TProtocolException => ttx
+          #print ttx,"\n"
+        ensure
+          trans.close()
         end
-      rescue TTransportException, TProtocolException => ttx
-        #print ttx,"\n"
-      ensure
-        trans.close()
       end
+    ensure
+      @serverTransport.close()
     end
   end
-
 end
 
 begin
Thrift/Ruby: TSimpleServer closes its listen socket on an uncaught exception.

Submitted by William Morgan.
Approved by Kevin Clark.


git-svn-id: <URL>