Skip to content
This repository has been archived by the owner on Apr 6, 2019. It is now read-only.

Commit

Permalink
fix Cylix/cpp_redis#132 (cpp_redis#32) - timeout for connection not w…
Browse files Browse the repository at this point in the history
…orking due to invalid param to select.
  • Loading branch information
Cylix committed Nov 13, 2017
1 parent 38b874d commit df072eb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sources/network/unix/unix_tcp_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ tcp_socket::connect(const std::string& host, std::uint32_t port, std::uint32_t t

//! 1 means we are connected.
//! 0/-1 means a timeout.
if (select(0, NULL, &set, NULL, &tv) == 1) {
if (select(m_fd + 1, NULL, &set, NULL, &tv) == 1) {
//! Set back to blocking mode as the user of this class is expecting
if (fcntl(m_fd, F_SETFL, fcntl(m_fd, F_GETFL, 0) & (~O_NONBLOCK)) == -1) {
close();
Expand Down
2 changes: 1 addition & 1 deletion sources/network/windows/windows_tcp_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ tcp_socket::connect(const std::string& host, std::uint32_t port, std::uint32_t t

//! 1 means we are connected.
//! 0 means a timeout.
if (select(0, NULL, &set, NULL, &tv) == 1) {
if (select(static_cast<int>(m_fd) + 1, NULL, &set, NULL, &tv) == 1) {
//! Set back to blocking mode as the user of this class is expecting
u_long mode = 0;
if (ioctlsocket(m_fd, FIONBIO, &mode) != 0) {
Expand Down

0 comments on commit df072eb

Please sign in to comment.