From ce330875f599c7287b33e61a7a6b957c4fe07c15 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Wed, 30 Jul 2014 09:44:18 +0000 Subject: [PATCH] Moved TCP slow timer handler to separate thread, to avoid possible deadlocks. git-svn-id: svn://kolibrios.org@5013 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/network/stack.inc | 7 ++++++- kernel/trunk/network/tcp.inc | 11 ++++++++++- kernel/trunk/network/tcp_timer.inc | 22 +++++++++++++--------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/kernel/trunk/network/stack.inc b/kernel/trunk/network/stack.inc index 544bb66d4d..9510f0ca57 100644 --- a/kernel/trunk/network/stack.inc +++ b/kernel/trunk/network/stack.inc @@ -313,10 +313,15 @@ stack_handler: test [net_10ms], 0x3f ; 640ms jnz .exit - TCP_timer_640ms ARP_decrease_entry_ttls IPv4_decrease_fragment_ttls + xor edx, edx + mov eax, [TCP_timer1_event] + mov ebx, [eax + EVENT.id] + xor esi, esi + call raise_event + .exit: ret diff --git a/kernel/trunk/network/tcp.inc b/kernel/trunk/network/tcp.inc index 1494788f87..69b388cf8d 100644 --- a/kernel/trunk/network/tcp.inc +++ b/kernel/trunk/network/tcp.inc @@ -141,6 +141,7 @@ align 4 TCP_sequence_num dd ? TCP_queue rd (TCP_QUEUE_SIZE*sizeof.TCP_queue_entry + sizeof.queue)/4 TCP_input_event dd ? + TCP_timer1_event dd ? endg uglobal @@ -224,7 +225,15 @@ macro TCP_init { call new_sys_threads test eax, eax jns @f - DEBUGF DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP, error %d\n', eax + DEBUGF DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP input, error %d\n', eax + @@: + + movi ebx, 1 + mov ecx, TCP_timer_640ms + call new_sys_threads + test eax, eax + jns @f + DEBUGF DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP timer, error %d\n', eax @@: } diff --git a/kernel/trunk/network/tcp_timer.inc b/kernel/trunk/network/tcp_timer.inc index a78f99134c..222d16e03b 100644 --- a/kernel/trunk/network/tcp_timer.inc +++ b/kernel/trunk/network/tcp_timer.inc @@ -61,13 +61,18 @@ local .exit } -;---------------------- -; 640 ms timer -;---------------------- -macro TCP_timer_640ms { ; TODO: implement timed wait timer! +align 4 +proc TCP_timer_640ms ; TODO: implement timed wait timer! -local .loop -local .exit + xor esi, esi + mov ecx, MANUAL_DESTROY + call create_event + mov [TCP_timer1_event], eax + + .wait: + mov eax, [TCP_timer1_event] + mov ebx, [eax + EVENT.id] + call wait_event ; Update TCP sequence number @@ -81,7 +86,7 @@ local .exit mov eax, [eax + SOCKET.NextPtr] .check_only: or eax, eax - jz .exit + jz .wait cmp [eax + SOCKET.Domain], AF_INET4 jne .loop @@ -157,9 +162,8 @@ local .exit mov [eax + TCP_SOCKET.t_force], 0 jmp .loop - .exit: -} +endp