Skip to content

Commit

Permalink
Merge pull request robinrodricks#287 from iamjay/tls_timeout_freeze
Browse files Browse the repository at this point in the history
Fix hang in TLS activation because no timeout is set on the underlying NetworkStream
  • Loading branch information
robinrodricks authored Apr 17, 2018
2 parents 7a2f256 + 343d6d4 commit 76e5447
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions FluentFTP/Stream/FtpSocketStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ public override int ReadTimeout {
}
set {
m_readTimeout = value;
if (m_netStream != null)
m_netStream.ReadTimeout = m_readTimeout;
}
}

Expand Down Expand Up @@ -814,6 +816,7 @@ public void Connect(string host, int port, FtpIpVersion ipVersions) {
}

m_netStream = new NetworkStream(m_socket);
m_netStream.ReadTimeout = m_readTimeout;
m_lastActivity = DateTime.Now;
}

Expand Down Expand Up @@ -891,6 +894,7 @@ public async Task ConnectAsync(string host, int port, FtpIpVersion ipVersions)
}

m_netStream = new NetworkStream(m_socket);
m_netStream.ReadTimeout = m_readTimeout;
m_lastActivity = DateTime.Now;
}
#endif
Expand Down Expand Up @@ -1127,6 +1131,7 @@ public async Task AcceptAsync() {
m_socket = await m_socket.AcceptAsync();
#if CORE
m_netStream = new NetworkStream(m_socket);
m_netStream.ReadTimeout = m_readTimeout;
#endif
}
}
Expand All @@ -1151,6 +1156,7 @@ public void EndAccept(IAsyncResult ar) {
if (m_socket != null) {
m_socket = m_socket.EndAccept(ar);
m_netStream = new NetworkStream(m_socket);
m_netStream.ReadTimeout = m_readTimeout;
}
}
#endif
Expand Down

0 comments on commit 76e5447

Please sign in to comment.