diff --git a/kernel/trunk/network/socket.inc b/kernel/trunk/network/socket.inc index a5db19dad5..5a30e1b2e6 100644 --- a/kernel/trunk/network/socket.inc +++ b/kernel/trunk/network/socket.inc @@ -608,22 +608,32 @@ align 4 .block: test [eax + SOCKET.options], SO_NONBLOCK - jz .loop + jz .waitforit mov dword[esp+20], EWOULDBLOCK mov dword[esp+32], -1 ret + .waitforit: + push eax + stdcall timer_hs, 300, 0, .wake, eax ; FIXME: make timeout a constant + pop eax + .loop: - cmp [eax + TCP_SOCKET.t_state], TCPS_CLOSED - je .fail + cmp [eax + SOCKET.errorcode], 0 + jne .fail cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED je .established - ja .fail call SOCKET_block jmp .loop + .wake: + mov eax, [esp+4] + mov [eax + SOCKET.errorcode], ETIMEDOUT + call SOCKET_notify.unblock + ret 4 + .fail: mov eax, [eax + SOCKET.errorcode] mov [esp+20], eax diff --git a/programs/network/telnet/telnet.asm b/programs/network/telnet/telnet.asm index 60db096d7c..ef86534fc6 100644 --- a/programs/network/telnet/telnet.asm +++ b/programs/network/telnet/telnet.asm @@ -160,6 +160,8 @@ resolve: mov [socketnum], eax mcall connect, [socketnum], sockaddr1, 18 + test eax, eax + jnz socket_err mcall 40, 1 shl 7 ; + 7 call [con_cls]