NET branch: Fixed errors in socket_open and socket_fork

git-svn-id: svn://kolibrios.org@2315 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2011-11-13 16:17:05 +00:00
parent 61a835651a
commit c518777ac6
3 changed files with 18 additions and 15 deletions

View File

@ -86,7 +86,7 @@ goto :eof
if not exist bin\lib mkdir bin\lib if not exist bin\lib mkdir bin\lib
cd applications\libraries cd applications\libraries
for %%a in (%libs%) do ( for %%a in (%libs%) do (
fasm -m 65536 %%a\%%a.asm ..\..\bin\libs\%%a.obj fasm -m 65536 %%a\%%a.asm ..\..\bin\lib\%%a.obj
if not %errorlevel%==0 goto :Error_FasmFailed if not %errorlevel%==0 goto :Error_FasmFailed
) )
cd ..\.. cd ..\..

View File

@ -269,7 +269,9 @@ SOCKET_open:
DEBUGF 1,"SOCKET_open: domain: %u, type: %u protocol: %x\n", ecx, edx, esi DEBUGF 1,"SOCKET_open: domain: %u, type: %u protocol: %x\n", ecx, edx, esi
push ecx edx esi
call SOCKET_alloc call SOCKET_alloc
pop esi edx ecx
jz s_error jz s_error
mov [esp+32], edi ; return socketnumber mov [esp+32], edi ; return socketnumber
@ -1308,7 +1310,7 @@ SOCKET_notify_owner:
align 4 align 4
SOCKET_alloc: SOCKET_alloc:
push ecx ebx push ebx
stdcall kernel_alloc, SOCKETBUFFSIZE stdcall kernel_alloc, SOCKETBUFFSIZE
DEBUGF 1, "SOCKET_alloc: ptr=%x\n", eax DEBUGF 1, "SOCKET_alloc: ptr=%x\n", eax
@ -1316,23 +1318,23 @@ SOCKET_alloc:
jz .exit jz .exit
; zero-initialize allocated memory ; zero-initialize allocated memory
push eax edi push eax
mov edi, eax mov edi, eax
mov ecx, SOCKETBUFFSIZE / 4 mov ecx, SOCKETBUFFSIZE / 4
xor eax, eax xor eax, eax
rep stosd rep stosd
pop edi eax pop eax
; set send-and receive procedures to return -1 ; set send-and receive procedures to return -1
mov [eax + SOCKET.snd_proc], s_error mov [eax + SOCKET.snd_proc], s_error
mov [eax + SOCKET.rcv_proc], s_error mov [eax + SOCKET.rcv_proc], s_error
; find first free socket number and use it ; find first free socket number and use it
mov ecx, [last_socket_num] mov edi, [last_socket_num]
.next_socket_number: .next_socket_number:
inc ecx inc edi
jz .next_socket_number ; avoid socket nr 0 jz .next_socket_number ; avoid socket nr 0
cmp ecx, -1 cmp edi, -1
je .next_socket_number ; avoid socket nr -1 je .next_socket_number ; avoid socket nr -1
mov ebx, net_sockets mov ebx, net_sockets
.next_socket: .next_socket:
@ -1340,15 +1342,14 @@ SOCKET_alloc:
test ebx, ebx test ebx, ebx
jz .last_socket jz .last_socket
cmp [ebx + SOCKET.Number], ecx cmp [ebx + SOCKET.Number], edi
jne .next_socket jne .next_socket
jmp .next_socket_number jmp .next_socket_number
.last_socket: .last_socket:
mov [last_socket_num], ecx mov [last_socket_num], edi
mov [eax + SOCKET.Number], ecx mov [eax + SOCKET.Number], edi
DEBUGF 1, "SOCKET_alloc: number=%u\n", ecx DEBUGF 1, "SOCKET_alloc: number=%u\n", edi
mov edi, ecx
; Fill in PID ; Fill in PID
mov ebx, [TASK_BASE] mov ebx, [TASK_BASE]
@ -1373,7 +1374,7 @@ SOCKET_alloc:
mov [net_sockets + SOCKET.NextPtr], eax mov [net_sockets + SOCKET.NextPtr], eax
or eax, eax ; used to clear zero flag or eax, eax ; used to clear zero flag
.exit: .exit:
pop ebx ecx pop ebx
ret ret
@ -1459,10 +1460,11 @@ SOCKET_fork:
jae .fail jae .fail
; Allocate new socket ; Allocate new socket
push ebx
call SOCKET_alloc call SOCKET_alloc
pop ebx
jz .fail jz .fail
push esi ecx edi
push eax push eax
mov esi, esp mov esi, esp
add_to_queue (ebx + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, .fail2 add_to_queue (ebx + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, .fail2
@ -1476,7 +1478,6 @@ SOCKET_fork:
rep movsd rep movsd
and [eax + SOCKET.options], not SO_ACCEPTCON and [eax + SOCKET.options], not SO_ACCEPTCON
pop edi ecx esi
ret ret

View File

@ -173,7 +173,9 @@ TCP_input:
DEBUGF 1,"Accepting new connection\n" DEBUGF 1,"Accepting new connection\n"
mov [ebx + SOCKET.lock], 0 mov [ebx + SOCKET.lock], 0
push ecx edx esi edi ;;;
call SOCKET_fork call SOCKET_fork
pop edi esi edx ecx
test eax, eax test eax, eax
jz .drop jz .drop