Fixing bug in async connect resulting in TCP fwding failures. scp on board (not functional yet)
This commit is contained in:
parent
83cad11f62
commit
2d47fc533a
17
channels.c
17
channels.c
|
@ -41,23 +41,6 @@
|
|||
|
||||
#include "includes.h"
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
//#define WIN32_PRAGMA_REMCON
|
||||
#ifdef ECONNABORTED
|
||||
#undef ECONNABORTED
|
||||
#endif
|
||||
#define ECONNABORTED WSAECONNABORTED
|
||||
#ifdef ECONNREFUSED
|
||||
#undef ECONNREFUSED
|
||||
#endif
|
||||
#define ECONNREFUSED WSAECONNREFUSED
|
||||
#ifdef EINPROGRESS
|
||||
#undef EINPROGRESS
|
||||
#endif
|
||||
#define EINPROGRESS WSAEINPROGRESS
|
||||
#define _CRT_NO_POSIX_ERROR_CODES
|
||||
#endif
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h> /* MIN MAX */
|
||||
|
|
|
@ -78,21 +78,25 @@
|
|||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(OpenSSH-Bin-Path)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\</IntDir>
|
||||
<IncludePath>$(OpenSSH-Src-Path)contrib\win32\win32compat\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -108,7 +112,7 @@
|
|||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -126,7 +130,7 @@
|
|||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Debug-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -148,7 +152,7 @@
|
|||
<GenerateDebugInformation>No</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-Win32-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -170,7 +174,7 @@
|
|||
<GenerateDebugInformation>No</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>win32iocompat.lib;bcrypt.lib;Userenv.lib;Ws2_32.lib;Secur32.lib;Shlwapi.lib;openbsd_compat.lib;libssh.lib;win32compat.lib;libeay32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OpenSSH-Lib-Path)$(Platform)\$(Configuration);$(OpenSSL-x64-Release-Path)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
|
@ -41,6 +41,24 @@
|
|||
|
||||
#define errno_from_WSALastError() errno_from_WSAError(WSAGetLastError())
|
||||
|
||||
|
||||
#ifdef WIN32_FIXME
|
||||
//#define WIN32_PRAGMA_REMCON
|
||||
#ifdef ECONNABORTED
|
||||
#undef ECONNABORTED
|
||||
#endif
|
||||
#define ECONNABORTED WSAECONNABORTED
|
||||
#ifdef ECONNREFUSED
|
||||
#undef ECONNREFUSED
|
||||
#endif
|
||||
#define ECONNREFUSED WSAECONNREFUSED
|
||||
#ifdef EINPROGRESS
|
||||
#undef EINPROGRESS
|
||||
#endif
|
||||
#define EINPROGRESS WSAEINPROGRESS
|
||||
#define _CRT_NO_POSIX_ERROR_CODES
|
||||
#endif
|
||||
|
||||
/* maps WSAError to errno */
|
||||
static
|
||||
int errno_from_WSAError(int wsaerrno)
|
||||
|
@ -52,10 +70,19 @@ int errno_from_WSAError(int wsaerrno)
|
|||
return EFAULT;
|
||||
case WSAEINVAL:
|
||||
return EINVAL;
|
||||
case WSAECONNABORTED:
|
||||
return ECONNABORTED;
|
||||
case WSAECONNREFUSED:
|
||||
return ECONNREFUSED;
|
||||
case WSAEINPROGRESS:
|
||||
return EINPROGRESS;
|
||||
case WSAESHUTDOWN:
|
||||
return ECONNRESET;
|
||||
case WSAENOTCONN:
|
||||
return ENOTCONN;
|
||||
default:
|
||||
return wsaerrno;
|
||||
/* */
|
||||
return wsaerrno - 10000;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,6 +383,8 @@ socketio_recv(struct w32_io* pio, void *buf, size_t len, int flags) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* TODO - ensure socket is in accepted or connected state */
|
||||
|
||||
/* /io is initiated and pending */
|
||||
if (pio->read_details.pending) {
|
||||
/* if recv is now in blocking mode, wait for data to be available */
|
||||
|
@ -466,7 +495,7 @@ socketio_recv(struct w32_io* pio, void *buf, size_t len, int flags) {
|
|||
else {
|
||||
/* this should not happen */
|
||||
errno = EOTHER;
|
||||
debug("recv - (2) ERROR:Unexpected IO stated, io:%p", pio);
|
||||
debug("recv - (2) ERROR:Unexpected IO state, io:%p", pio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -516,6 +545,8 @@ socketio_send(struct w32_io* pio, const void *buf, size_t len, int flags) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* TODO - ensure socket is in accepted or connected state */
|
||||
|
||||
/* if io is already pending */
|
||||
if (pio->write_details.pending)
|
||||
{
|
||||
|
@ -853,15 +884,23 @@ socketio_connect(struct w32_io* pio, const struct sockaddr* name, int namelen) {
|
|||
|
||||
}
|
||||
|
||||
return socketio_finish_connect(pio);
|
||||
}
|
||||
|
||||
int
|
||||
socketio_finish_connect(struct w32_io* pio) {
|
||||
|
||||
debug3("finish_connect, io:%p", pio);
|
||||
|
||||
if (pio->write_details.error) {
|
||||
errno = errno_from_WSAError(pio->write_details.error);
|
||||
debug("connect - ERROR: async io completed with error: %d, io:%p", errno, pio);
|
||||
debug("finish_connect - ERROR: async io completed with error: %d, io:%p", errno, pio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 != setsockopt(pio->sock, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0)) {
|
||||
errno = errno_from_WSALastError();
|
||||
debug("connect - ERROR: setsockopt failed:%d, io:%p", errno, pio);
|
||||
debug("finish_connect - ERROR: setsockopt failed:%d, io:%p", errno, pio);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -610,6 +610,10 @@ w32_select(int fds, w32_fd_set* readfds, w32_fd_set* writefds, w32_fd_set* excep
|
|||
if (writefds && FD_ISSET(i, writefds)) {
|
||||
in_set_fds++;
|
||||
if (w32_io_is_io_available(fd_table.w32_ios[i], FALSE)) {
|
||||
/* for connect() completed sockets finish WSA connect process*/
|
||||
if ((fd_table.w32_ios[i]->type == SOCK_FD)
|
||||
&& ((fd_table.w32_ios[i]->internal.state == SOCK_CONNECTING)))
|
||||
socketio_finish_connect(fd_table.w32_ios[i]);
|
||||
FD_SET(i, &write_ready_fds);
|
||||
out_ready_fds++;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ int socketio_getpeername(struct w32_io* pio, struct sockaddr* name, int* namelen
|
|||
int socketio_listen(struct w32_io* pio, int backlog);
|
||||
int socketio_bind(struct w32_io* pio, const struct sockaddr *name, int namelen);
|
||||
int socketio_connect(struct w32_io* pio, const struct sockaddr* name, int namelen);
|
||||
int socketio_finish_connect(struct w32_io* pio);
|
||||
int socketio_recv(struct w32_io* pio, void *buf, size_t len, int flags);
|
||||
int socketio_send(struct w32_io* pio, const void *buf, size_t len, int flags);
|
||||
int socketio_shutdown(struct w32_io* pio, int how);
|
||||
|
|
Loading…
Reference in New Issue