comparison src/ch/ethz/ssh2/transport/TransportManager.java @ 322:a713e91c59c8 ganymed

add ecdsa key support everywhere
author Carl Byington <carl@five-ten-sg.com>
date Thu, 31 Jul 2014 09:03:50 -0700
parents c19b24adf6c9
children 90537ba71897
comparison
equal deleted inserted replaced
321:c19b24adf6c9 322:a713e91c59c8
131 private Throwable reasonClosedCause; 131 private Throwable reasonClosedCause;
132 132
133 private TransportConnection tc; 133 private TransportConnection tc;
134 private KexManager km; 134 private KexManager km;
135 135
136 private final List<HandlerEntry> messageHandlers 136 private final List<HandlerEntry> messageHandlers = new ArrayList<HandlerEntry>();
137 = new ArrayList<HandlerEntry>(); 137
138 138 private List<ConnectionMonitor> connectionMonitors = new ArrayList<ConnectionMonitor>();
139 private List<ConnectionMonitor> connectionMonitors 139 boolean monitorsWereInformed = false;
140 = new ArrayList<ConnectionMonitor>();
141 140
142 protected void init(TransportConnection tc, KexManager km) { 141 protected void init(TransportConnection tc, KexManager km) {
143 this.tc = tc; 142 this.tc = tc;
144 this.km = km; 143 this.km = km;
145 } 144 }
150 149
151 public ConnectionInfo getConnectionInfo(int kexNumber) throws IOException { 150 public ConnectionInfo getConnectionInfo(int kexNumber) throws IOException {
152 return km.getOrWaitForConnectionInfo(kexNumber); 151 return km.getOrWaitForConnectionInfo(kexNumber);
153 } 152 }
154 153
155 public IOException getReasonClosedCause() { 154 public Throwable getReasonClosedCause() {
156 synchronized (connectionSemaphore) { 155 synchronized (connectionSemaphore) {
157 return reasonClosedCause; 156 return reasonClosedCause;
158 } 157 }
159 } 158 }
160 159
190 try { 189 try {
191 socket.close(); 190 socket.close();
192 } 191 }
193 catch (IOException ignore) { 192 catch (IOException ignore) {
194 } 193 }
195 194 }
196 connectionClosed = true; 195 connectionClosed = true;
197 reasonClosedCause = cause; 196 reasonClosedCause = cause;
198 197 }
199 synchronized (this) {
200 for (ConnectionMonitor cmon : connectionMonitors) {
201 try {
202 cmon.connectionLost(reasonClosedCause);
203 }
204 catch (Exception ignore) {
205 }
206 }
207 }
208 }
209
210 connectionSemaphore.notifyAll(); 198 connectionSemaphore.notifyAll();
199 }
200
201 // check if we need to inform the monitors
202 List monitors = null;
203
204 synchronized (this) {
205 // Short term lock to protect "connectionMonitors"
206 // and "monitorsWereInformed"
207 // (they may be modified concurrently)
208 if (monitorsWereInformed == false) {
209 monitorsWereInformed = true;
210 monitors = (List) connectionMonitors.clone();
211 }
212 }
213
214 if (monitors != null) {
215 for (ConnectionMonitor cmon : monitors) {
216 try {
217 cmon.connectionLost(reasonClosedCause);
218 }
219 catch (Exception ignore) {
220 }
221 }
211 } 222 }
212 } 223 }
213 224
214 protected void startReceiver() throws IOException { 225 protected void startReceiver() throws IOException {
215 final Thread receiveThread = new Thread(new Runnable() { 226 final Thread receiveThread = new Thread(new Runnable() {