1 21 22 package org.apache.derby.impl.drda; 23 24 import java.io.*; 25 import java.net.*; 26 import java.security.*; 27 28 final class ClientThread extends Thread { 29 30 NetworkServerControlImpl parent; 31 ServerSocket serverSocket; 32 private int timeSlice; 33 private int connNum; 34 35 ClientThread (NetworkServerControlImpl nsi, ServerSocket ss) { 36 37 NetworkServerControlImpl.setUniqueThreadName(this, "NetworkServerThread"); 40 41 parent=nsi; 42 serverSocket=ss; 43 timeSlice=nsi.getTimeSlice(); 44 } 45 46 public void run() 47 { 48 49 Socket clientSocket = null; 50 51 52 for (;;) 53 { 54 try { 55 try{ 56 clientSocket = (Socket) AccessController.doPrivileged( 57 new PrivilegedExceptionAction() { 58 public Object run() throws IOException 59 { 60 return serverSocket.accept(); 61 } 62 } 63 ); 64 clientSocket.setKeepAlive(parent.getKeepAlive()); 65 if (timeSlice != 0) 68 clientSocket.setSoTimeout(timeSlice); 69 } catch (PrivilegedActionException e) { 70 Exception e1 = e.getException(); 71 if (e1 instanceof IOException){ 72 synchronized(parent.getShutdownSync()) { 73 if (!parent.getShutdown()) 74 parent.consolePropertyMessage("DRDA_UnableToAccept.S"); 75 } 76 } else throw e1; 77 break; 78 } 80 parent.addSession(clientSocket); 82 83 }catch (Exception e) { 84 if (e instanceof InterruptedException ) 85 return; 86 parent.consoleExceptionPrintTrace(e); 87 } } 90 }} 92 93 94 95 96 97 98 99 | Popular Tags |