diff --git a/kernel/trunk/network/socket.inc b/kernel/trunk/network/socket.inc index d212fe163e..ddc71dc145 100644 --- a/kernel/trunk/network/socket.inc +++ b/kernel/trunk/network/socket.inc @@ -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 diff --git a/kernel/trunk/network/tcp_input.inc b/kernel/trunk/network/tcp_input.inc index f778bdb49e..dd3bc9187c 100644 --- a/kernel/trunk/network/tcp_input.inc +++ b/kernel/trunk/network/tcp_input.inc @@ -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 diff --git a/kernel/trunk/network/tcp_output.inc b/kernel/trunk/network/tcp_output.inc index b3fd2ae952..fe616d81aa 100644 --- a/kernel/trunk/network/tcp_output.inc +++ b/kernel/trunk/network/tcp_output.inc @@ -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 diff --git a/kernel/trunk/network/tcp_usreq.inc b/kernel/trunk/network/tcp_usreq.inc index 9e219e93ef..3ed7b32d28 100644 --- a/kernel/trunk/network/tcp_usreq.inc +++ b/kernel/trunk/network/tcp_usreq.inc @@ -97,6 +97,9 @@ TCP_disconnect: call SOCKET_is_disconnecting call TCP_usrclosed + + push eax call TCP_output + pop eax ret \ No newline at end of file