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
cd applications\libraries
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
)
cd ..\..

View File

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

View File

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