More TCP updates + Socket states

git-svn-id: svn://kolibrios.org@1773 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2011-01-28 16:49:08 +00:00
parent 2861c164de
commit 2ba52e3e4a
4 changed files with 92 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -111,4 +111,25 @@ local .exit
jmp .loop
.exit:
}
}
; 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