diff src/ch/ethz/ssh2/channel/ChannelManager.java @ 289:d2ee20d9dff1 ganymed

start conversion from trilead to ganymed
author Carl Byington <carl@five-ten-sg.com>
date Fri, 18 Jul 2014 20:17:53 -0700
parents 5824a1475be4
children 9ae4ed7bb523
line wrap: on
line diff
--- a/src/ch/ethz/ssh2/channel/ChannelManager.java	Fri Jul 18 19:59:32 2014 -0700
+++ b/src/ch/ethz/ssh2/channel/ChannelManager.java	Fri Jul 18 20:17:53 2014 -0700
@@ -12,6 +12,7 @@
 import java.util.List;
 import java.util.Map;
 
+import ch.ethz.ssh2.AuthAgentCallback;
 import ch.ethz.ssh2.ChannelCondition;
 import ch.ethz.ssh2.PacketFormatException;
 import ch.ethz.ssh2.PacketTypeException;
@@ -466,7 +467,7 @@
      * @param agent
      * @throws IOException
      */
-    public boolean requestChannelAgentForwarding(Channel c, AuthAgentCallback authAgent) throws IOException {
+    public void requestChannelAgentForwarding(Channel c, AuthAgentCallback authAgent) throws IOException {
         synchronized (this) {
             if (this.authAgent != null)
                 throw new IllegalStateException("Auth agent already exists");
@@ -481,9 +482,17 @@
         log.debug("Requesting agent forwarding");
 
         PacketChannelAuthAgentReq aar = new PacketChannelAuthAgentReq(c.remoteID);
-        tm.sendMessage(aar.getPayload());
+        synchronized(c.channelSendLock) {
+            if (c.closeMessageSent) {
+                throw c.getReasonClosed();
+            }
+            tm.sendMessage(aar.getPayload());
+        }
 
-        if (waitForChannelRequestResult(c) == false) {
+        try {
+            waitForChannelSuccessOrFailure(c);
+        }
+        catch(IOException e) {
             authAgent = null;
             return false;
         }