forked from KolibriOS/kolibrios
Bugixes and improvements for closing TCP sockets.
git-svn-id: svn://kolibrios.org@3652 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
de3f768cbf
commit
52556729d6
@ -729,7 +729,6 @@ SOCKET_close:
|
||||
|
||||
mov dword [esp+32], 0 ; The socket exists, so we will succeed in closing it.
|
||||
|
||||
.socket:
|
||||
or [eax + SOCKET.options], SO_NONBLOCK ; Mark the socket as non blocking, we dont want it to block any longer!
|
||||
|
||||
test [eax + SOCKET.state], SS_BLOCKED ; Is the socket still in blocked state?
|
||||
@ -1924,16 +1923,16 @@ SOCKET_free:
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: %x\n", eax
|
||||
|
||||
call SOCKET_check
|
||||
jz .error
|
||||
|
||||
push ebx
|
||||
|
||||
pusha
|
||||
mov ecx, socket_mutex
|
||||
call mutex_lock
|
||||
popa
|
||||
|
||||
call SOCKET_check
|
||||
jz .error
|
||||
|
||||
push ebx
|
||||
|
||||
pusha
|
||||
lea ecx, [eax + SOCKET.mutex]
|
||||
call mutex_lock
|
||||
@ -1951,6 +1950,7 @@ SOCKET_free:
|
||||
mov eax, ebx
|
||||
.no_tcp:
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: freeing socket %x\n", eax
|
||||
push eax ; this will be passed to kernel_free
|
||||
mov ebx, [eax + SOCKET.NextPtr]
|
||||
mov eax, [eax + SOCKET.PrevPtr]
|
||||
@ -1970,14 +1970,15 @@ SOCKET_free:
|
||||
call kernel_free
|
||||
pop ebx
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: success!\n"
|
||||
|
||||
.error:
|
||||
|
||||
pusha
|
||||
mov ecx, socket_mutex
|
||||
call mutex_unlock
|
||||
popa
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: success!\n"
|
||||
|
||||
.error:
|
||||
ret
|
||||
|
||||
;------------------------------------
|
||||
@ -2125,11 +2126,6 @@ SOCKET_check:
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_check: %x\n", eax
|
||||
|
||||
pusha
|
||||
mov ecx, socket_mutex
|
||||
call mutex_lock
|
||||
popa
|
||||
|
||||
push ebx
|
||||
mov ebx, net_sockets
|
||||
|
||||
@ -2145,11 +2141,6 @@ SOCKET_check:
|
||||
test eax, eax
|
||||
pop ebx
|
||||
|
||||
pusha
|
||||
mov ecx, socket_mutex
|
||||
call mutex_unlock
|
||||
popa
|
||||
|
||||
ret
|
||||
|
||||
|
||||
@ -2229,7 +2220,19 @@ SOCKET_process_end:
|
||||
popa
|
||||
|
||||
pusha
|
||||
call SOCKET_close.socket
|
||||
cmp [eax + SOCKET.Domain], AF_INET4
|
||||
jne .free
|
||||
|
||||
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP
|
||||
jne .free
|
||||
|
||||
call TCP_close
|
||||
jmp .closed
|
||||
|
||||
.free:
|
||||
call SOCKET_free
|
||||
|
||||
.closed:
|
||||
popa
|
||||
|
||||
pusha
|
||||
|
@ -1170,9 +1170,17 @@ TCP_process_input:
|
||||
.ack_la:
|
||||
jnc .ack_processed
|
||||
|
||||
push ebx
|
||||
lea ecx, [ebx + SOCKET.mutex]
|
||||
call mutex_unlock
|
||||
pop ebx
|
||||
|
||||
push ebx
|
||||
mov eax, ebx
|
||||
call TCP_disconnect
|
||||
jmp .drop
|
||||
pop ebx
|
||||
|
||||
jmp .destroy_new_socket
|
||||
|
||||
.ack_tw:
|
||||
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
||||
|
@ -35,6 +35,8 @@ TCP_output:
|
||||
call mutex_lock
|
||||
pop eax
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: socket locked\n"
|
||||
|
||||
; We'll detect the length of the data to be transmitted, and flags to be used
|
||||
; If there is some data, or any critical controls to send (SYN / RST), then transmit
|
||||
; Otherwise, investigate further
|
||||
@ -216,6 +218,7 @@ TCP_output:
|
||||
mov ebx, TCP_max_win
|
||||
shl ebx, cl
|
||||
pop ecx
|
||||
|
||||
cmp ebx, ecx
|
||||
jb @f
|
||||
mov ebx, ecx
|
||||
@ -571,6 +574,8 @@ TCP_send:
|
||||
;--------------
|
||||
; unlock socket
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: unlocking socket 0x%x\n", eax
|
||||
|
||||
push eax
|
||||
lea ecx, [eax + SOCKET.mutex]
|
||||
call mutex_unlock
|
||||
@ -607,7 +612,8 @@ TCP_send:
|
||||
|
||||
|
||||
.send_error:
|
||||
add esp, 8
|
||||
add esp, 4
|
||||
pop eax
|
||||
|
||||
lea ecx, [eax + SOCKET.mutex]
|
||||
call mutex_unlock
|
||||
|
@ -97,6 +97,9 @@ TCP_disconnect:
|
||||
|
||||
call SOCKET_is_disconnecting
|
||||
call TCP_usrclosed
|
||||
|
||||
push eax
|
||||
call TCP_output
|
||||
pop eax
|
||||
|
||||
ret
|
Loading…
Reference in New Issue
Block a user