diff --git a/kernel/branches/net/network/socket.inc b/kernel/branches/net/network/socket.inc index 2f6020375c..a9ece3359b 100644 --- a/kernel/branches/net/network/socket.inc +++ b/kernel/branches/net/network/socket.inc @@ -15,6 +15,7 @@ $Revision$ + virtual at 0 SOCKET: @@ -1680,3 +1681,46 @@ SOCKET_process_end: pop ebx ret + + + + + + + + +;----------------------------------------------------------------- +; +; SOCKET_is_disconnecting +; +; IN: eax = socket ptr +; OUT: / +; +;----------------------------------------------------------------- + +align 4 +SOCKET_is_disconnecting: + + and [eax + SOCKET.options], not (SS_ISCONNECTING) + or [eax + SOCKET.options], SS_ISDISCONNECTING + SS_CANTRCVMORE + SS_CANTSENDMORE + + jmp SOCKET_notify_owner + + + +;----------------------------------------------------------------- +; +; SOCKET_is_disconnected +; +; IN: eax = socket ptr +; OUT: / +; +;----------------------------------------------------------------- + +align 4 +SOCKET_is_disconnected: + + and [eax + SOCKET.options], not (SS_ISCONNECTING + SS_ISCONNECTED + SS_ISDISCONNECTING) + or [eax + SOCKET.options], SS_CANTRCVMORE + SS_CANTSENDMORE + + jmp SOCKET_notify_owner diff --git a/kernel/branches/net/network/stack.inc b/kernel/branches/net/network/stack.inc index eba49ac10d..603a8ae7e5 100644 --- a/kernel/branches/net/network/stack.inc +++ b/kernel/branches/net/network/stack.inc @@ -62,6 +62,23 @@ SOCK_RAW equ 3 ; Socket options SO_ACCEPTCON equ 1 +; Socket States +SS_NOFDREF equ 0x001 ; no file table ref any more +SS_ISCONNECTED equ 0x002 ; socket connected to a peer +SS_ISCONNECTING equ 0x004 ; in process of connecting to peer +SS_ISDISCONNECTING equ 0x008 ; in process of disconnecting +SS_CANTSENDMORE equ 0x010 ; can't send more data to peer +SS_CANTRCVMORE equ 0x020 ; can't receive more data from peer +SS_RCVATMARK equ 0x040 ; at mark on input +SS_ISABORTING equ 0x080 ; aborting fd references - close() +SS_RESTARTSYS equ 0x100 ; restart blocked system calls +SS_ISDISCONNECTED equ 0x800 ; socket disconnected from peer + +SS_ASYNC equ 0x100 ; async i/o notify +SS_ISCONFIRMING equ 0x200 ; deciding to accept connection req +SS_MORETOCOME equ 0x400 ; + + SOCKET_MAXDATA equ 4096*32 ; must be 4096*(power of 2) where 'power of 2' is at least 8 ; Network driver types diff --git a/kernel/branches/net/network/tcp_input.inc b/kernel/branches/net/network/tcp_input.inc index 34f0d99637..daeb1d1d3f 100644 --- a/kernel/branches/net/network/tcp_input.inc +++ b/kernel/branches/net/network/tcp_input.inc @@ -1129,10 +1129,11 @@ align 4 .ack_fw1: jz .ack_processed - test [ebx + SOCKET.state], SO_CANTRCVMORE + test [ebx + SOCKET.state], SS_CANTRCVMORE jnz @f - ;;soisdisconnected(ebx) - mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle + mov eax, ebx + call SOCKET_is_disconnected +;;; mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle @@: mov [ebx + TCP_SOCKET.t_state], TCB_FIN_WAIT_2 @@ -1143,15 +1144,19 @@ align 4 jz .ack_processed mov [ebx + TCP_SOCKET.t_state], TCB_TIMED_WAIT + mov eax, ebx call TCP_cancel_timers mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL - ;;soisdisconnected(ebx) + mov eax, ebx + call SOCKET_is_disconnected jmp .ack_processed .ack_la: jz .ack_processed + + mov eax, ebx call TCP_close jmp .drop diff --git a/kernel/branches/net/network/tcp_timer.inc b/kernel/branches/net/network/tcp_timer.inc index acd1c90e8e..6815d88be2 100644 --- a/kernel/branches/net/network/tcp_timer.inc +++ b/kernel/branches/net/network/tcp_timer.inc @@ -111,4 +111,25 @@ local .exit jmp .loop .exit: -} \ No newline at end of file +} + + + +; eax = socket + +TCP_cancel_timers: + + push eax edi + + lea edi, [eax + TCP_SOCKET.timer_retransmission] + xor eax, eax + stosd + stosd + stosd + stosd + stosd + + pop edi eax + + + ret \ No newline at end of file