src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java
changeset 59300 60bdcb9a7b94
parent 47216 71c04702a3d5
equal deleted inserted replaced
59299:17d242844fc9 59300:60bdcb9a7b94
   271      * server socket if the count reaches zero.
   271      * server socket if the count reaches zero.
   272      **/
   272      **/
   273     private void decrementExportCount() {
   273     private void decrementExportCount() {
   274         assert Thread.holdsLock(this);
   274         assert Thread.holdsLock(this);
   275         exportCount--;
   275         exportCount--;
       
   276         if (tcpLog.isLoggable(Log.VERBOSE)) {
       
   277             tcpLog.log(Log.VERBOSE,
       
   278                     "server socket: " + server + ", exportCount: " + exportCount);
       
   279         }
   276         if (exportCount == 0 && getEndpoint().getListenPort() != 0) {
   280         if (exportCount == 0 && getEndpoint().getListenPort() != 0) {
   277             ServerSocket ss = server;
   281             ServerSocket ss = server;
   278             server = null;
   282             server = null;
   279             try {
   283             try {
       
   284                 if (tcpLog.isLoggable(Log.BRIEF)) {
       
   285                     tcpLog.log(Log.BRIEF, "server socket close: " + ss);
       
   286                 }
   280                 ss.close();
   287                 ss.close();
   281             } catch (IOException e) {
   288             } catch (IOException e) {
       
   289                 if (tcpLog.isLoggable(Log.BRIEF)) {
       
   290                     tcpLog.log(Log.BRIEF,
       
   291                             "server socket close throws: " + e);
       
   292                 }
   282             }
   293             }
   283         }
   294         }
   284     }
   295     }
   285 
   296 
   286     /**
   297     /**
   364         public void run() {
   375         public void run() {
   365             try {
   376             try {
   366                 executeAcceptLoop();
   377                 executeAcceptLoop();
   367             } finally {
   378             } finally {
   368                 try {
   379                 try {
       
   380                     if (tcpLog.isLoggable(Log.BRIEF)) {
       
   381                         tcpLog.log(Log.BRIEF,
       
   382                                 "server socket close: " + serverSocket);
       
   383                     }
   369                     /*
   384                     /*
   370                      * Only one accept loop is started per server
   385                      * Only one accept loop is started per server
   371                      * socket, so after no more connections will be
   386                      * socket, so after no more connections will be
   372                      * accepted, ensure that the server socket is no
   387                      * accepted, ensure that the server socket is no
   373                      * longer listening.
   388                      * longer listening.
   374                      */
   389                      */
   375                     serverSocket.close();
   390                     serverSocket.close();
   376                 } catch (IOException e) {
   391                 } catch (IOException e) {
       
   392                     if (tcpLog.isLoggable(Log.BRIEF)) {
       
   393                         tcpLog.log(Log.BRIEF,
       
   394                                 "server socket close throws: " + e);
       
   395                     }
   377                 }
   396                 }
   378             }
   397             }
   379         }
   398         }
   380 
   399 
   381         /**
   400         /**
   522     }
   541     }
   523 
   542 
   524     /** close socket and eat exception */
   543     /** close socket and eat exception */
   525     private static void closeSocket(Socket sock) {
   544     private static void closeSocket(Socket sock) {
   526         try {
   545         try {
       
   546             if (tcpLog.isLoggable(Log.BRIEF)) {
       
   547                 tcpLog.log(Log.BRIEF, "socket close: " + sock);
       
   548             }
   527             sock.close();
   549             sock.close();
   528         } catch (IOException ex) {
   550         } catch (IOException ex) {
   529             // eat exception
   551             // eat exception
       
   552             if (tcpLog.isLoggable(Log.BRIEF)) {
       
   553                 tcpLog.log(Log.BRIEF, "socket close throws: " + ex);
       
   554             }
   530         }
   555         }
   531     }
   556     }
   532 
   557 
   533     /**
   558     /**
   534      * handleMessages decodes transport operations and handles messages
   559      * handleMessages decodes transport operations and handles messages
   589         } finally {
   614         } finally {
   590             try {
   615             try {
   591                 conn.close();
   616                 conn.close();
   592             } catch (IOException ex) {
   617             } catch (IOException ex) {
   593                 // eat exception
   618                 // eat exception
       
   619                 if (tcpLog.isLoggable(Log.BRIEF)) {
       
   620                     tcpLog.log(Log.BRIEF, "Connection close throws " + ex);
       
   621                 }
   594             }
   622             }
   595         }
   623         }
   596     }
   624     }
   597 
   625 
   598     /**
   626     /**
   721                     version != TransportConstants.Version) {
   749                     version != TransportConstants.Version) {
   722                     // protocol mismatch detected...
   750                     // protocol mismatch detected...
   723                     // just close socket: this would recurse if we marshal an
   751                     // just close socket: this would recurse if we marshal an
   724                     // exception to the client and the protocol at other end
   752                     // exception to the client and the protocol at other end
   725                     // doesn't match.
   753                     // doesn't match.
       
   754                     if (tcpLog.isLoggable(Log.BRIEF)) {
       
   755                         tcpLog.log(Log.BRIEF, "magic or version not match: "
       
   756                                                   + magic + ", " + version);
       
   757                     }
   726                     closeSocket(socket);
   758                     closeSocket(socket);
   727                     return;
   759                     return;
   728                 }
   760                 }
   729 
   761 
   730                 OutputStream sockOut = socket.getOutputStream();
   762                 OutputStream sockOut = socket.getOutputStream();