Correct TCP socket closing after keepalive expires.

git-svn-id: svn://kolibrios.org@2879 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-07-17 22:20:18 +00:00
parent ffd03b26b7
commit 3c7b5955e3

View File

@ -19,33 +19,33 @@ $Revision$
;---------------------- ;----------------------
; 160 ms timer ; 160 ms timer
;---------------------- ;----------------------
macro TCP_timer_160ms { macro TCP_timer_160ms {
local .loop local .loop
local .exit local .exit
mov ebx, net_sockets mov ebx, net_sockets
.loop: .loop:
mov ebx, [ebx + SOCKET.NextPtr] mov ebx, [ebx + SOCKET.NextPtr]
or ebx, ebx or ebx, ebx
jz .exit jz .exit
cmp [ebx + SOCKET.Domain], AF_INET4 cmp [ebx + SOCKET.Domain], AF_INET4
jne .loop jne .loop
cmp [ebx + SOCKET.Protocol], IP_PROTO_TCP cmp [ebx + SOCKET.Protocol], IP_PROTO_TCP
jne .loop jne .loop
test [ebx + TCP_SOCKET.t_flags], TF_DELACK test [ebx + TCP_SOCKET.t_flags], TF_DELACK
jz .loop jz .loop
and [ebx + TCP_SOCKET.t_flags], not (TF_DELACK) and [ebx + TCP_SOCKET.t_flags], not (TF_DELACK)
push ebx push ebx
mov cl, TH_ACK mov cl, TH_ACK
call TCP_respond_socket call TCP_respond_socket
pop ebx pop ebx
jmp .loop jmp .loop
.exit: .exit:
@ -55,63 +55,63 @@ local .exit
;---------------------- ;----------------------
; 640 ms timer ; 640 ms timer
;---------------------- ;----------------------
macro TCP_timer_640ms { macro TCP_timer_640ms {
local .loop local .loop
local .exit local .exit
; Update TCP sequence number ; Update TCP sequence number
add [TCP_sequence_num], 64000 add [TCP_sequence_num], 64000
; scan through all the active TCP sockets, decrementing ALL timers ; scan through all the active TCP sockets, decrementing ALL timers
; timers do not have the chance to wrap because the keepalive timer will kill the socket when it expires ; timers do not have the chance to wrap because the keepalive timer will kill the socket when it expires
mov eax, net_sockets mov eax, net_sockets
.loop: .loop:
mov eax, [eax + SOCKET.NextPtr] mov eax, [eax + SOCKET.NextPtr]
.check_only: .check_only:
or eax, eax or eax, eax
jz .exit jz .exit
cmp [eax + SOCKET.Domain], AF_INET4 cmp [eax + SOCKET.Domain], AF_INET4
jne .loop jne .loop
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP cmp [eax + SOCKET.Protocol], IP_PROTO_TCP
jne .loop jne .loop
inc [eax + TCP_SOCKET.t_idle] inc [eax + TCP_SOCKET.t_idle]
dec [eax + TCP_SOCKET.timer_retransmission] dec [eax + TCP_SOCKET.timer_retransmission]
jnz .check_more2 jnz .check_more2
DEBUGF 1,"socket %x: Retransmission timer expired\n", eax DEBUGF 1,"socket %x: Retransmission timer expired\n", eax
push eax push eax
call TCP_output call TCP_output
pop eax pop eax
.check_more2: .check_more2:
dec [eax + TCP_SOCKET.timer_keepalive] dec [eax + TCP_SOCKET.timer_keepalive]
jnz .check_more3 jnz .check_more3
DEBUGF 1,"socket %x: Keepalive expired\n", eax DEBUGF 1,"socket %x: Keepalive expired\n", eax
call TCP_close call TCP_disconnect
jmp .loop jmp .loop
.check_more3: .check_more3:
dec [eax + TCP_SOCKET.timer_timed_wait] dec [eax + TCP_SOCKET.timer_timed_wait]
jnz .check_more5 jnz .check_more5
DEBUGF 1,"socket %x: 2MSL timer expired\n", eax DEBUGF 1,"socket %x: 2MSL timer expired\n", eax
.check_more5: .check_more5:
dec [eax + TCP_SOCKET.timer_persist] dec [eax + TCP_SOCKET.timer_persist]
jnz .loop jnz .loop
DEBUGF 1,"socket %x: persist timer expired\n", eax DEBUGF 1,"socket %x: persist timer expired\n", eax
jmp .loop jmp .loop
.exit: .exit:
} }
@ -122,17 +122,17 @@ local .exit
TCP_cancel_timers: TCP_cancel_timers:
push eax edi push eax edi
lea edi, [eax + TCP_SOCKET.timer_retransmission] lea edi, [eax + TCP_SOCKET.timer_retransmission]
xor eax, eax xor eax, eax
stosd stosd
stosd stosd
stosd stosd
stosd stosd
stosd stosd
pop edi eax pop edi eax
ret ret