SOCKET_receive: bugfixes, return 0 when remote end closed connection.

git-svn-id: svn://kolibrios.org@4219 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-11-12 20:05:57 +00:00
parent eba6e09237
commit c6d3f29329

View File

@ -755,15 +755,15 @@ SOCKET_receive:
call [eax + SOCKET.rcv_proc] call [eax + SOCKET.rcv_proc]
pop edi pop edi
test [eax + SOCKET.state], SS_CANTRCVMORE
jnz .return
cmp ebx, EWOULDBLOCK cmp ebx, EWOULDBLOCK
jne .return jne .return
test edi, MSG_DONTWAIT test edi, MSG_DONTWAIT
jnz .return_err jnz .return_err
test [eax + SOCKET.state], SS_CANTRCVMORE
jnz .return_err
; test [eax + SOCKET.options], SO_NONBLOCK ; test [eax + SOCKET.options], SO_NONBLOCK
; jnz .return_err ; jnz .return_err
@ -775,10 +775,10 @@ SOCKET_receive:
push EINVAL push EINVAL
pop ebx pop ebx
.return_err: .return_err:
mov eax, -1 mov ecx, -1
.return: .return:
mov [esp+20], ebx mov [esp+20], ebx
mov [esp+32], eax mov [esp+32], ecx
ret ret
@ -799,7 +799,7 @@ SOCKET_receive_dgram:
cmp ecx, ebx ; If data segment does not fit in applications buffer, abort cmp ecx, ebx ; If data segment does not fit in applications buffer, abort
ja .too_small ja .too_small
push ecx push eax ecx
push [esi + socket_queue_entry.buf_ptr] ; save the buffer addr so we can clear it later push [esi + socket_queue_entry.buf_ptr] ; save the buffer addr so we can clear it later
mov esi, [esi + socket_queue_entry.data_ptr] mov esi, [esi + socket_queue_entry.data_ptr]
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: Source buffer=%x real addr=%x\n", [esp], esi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: Source buffer=%x real addr=%x\n", [esp], esi
@ -820,12 +820,12 @@ SOCKET_receive_dgram:
.nd: .nd:
call NET_packet_free call NET_packet_free
pop eax ; return number of bytes copied to application pop ecx eax ; return number of bytes copied to application
xor ebx, ebx xor ebx, ebx
ret ret
.too_small: .too_small:
mov eax, -1 mov ecx, -1
push EMSGSIZE push EMSGSIZE
pop ebx pop ebx
ret ret
@ -870,21 +870,23 @@ SOCKET_receive_stream:
mov edi, edx mov edi, edx
xor edx, edx xor edx, edx
push eax
add eax, STREAM_SOCKET.rcv add eax, STREAM_SOCKET.rcv
call SOCKET_ring_read ; copy data from kernel buffer to application buffer call SOCKET_ring_read ; copy data from kernel buffer to application buffer
call SOCKET_ring_free ; free read memory call SOCKET_ring_free ; free read memory
pop eax
mov eax, ecx ; return number of bytes copied
xor ebx, ebx ; errorcode = 0 (no error) xor ebx, ebx ; errorcode = 0 (no error)
ret ret
.wouldblock: .wouldblock:
push EWOULDBLOCK push EWOULDBLOCK
pop ebx pop ebx
xor ecx, ecx
ret ret
.peek: .peek:
mov eax, [eax + STREAM_SOCKET.rcv + RING_BUFFER.size] mov ecx, [eax + STREAM_SOCKET.rcv + RING_BUFFER.size]
xor ebx, ebx xor ebx, ebx
ret ret
@ -2083,6 +2085,7 @@ SOCKET_num_to_ptr:
mov eax, [eax + SOCKET.NextPtr] mov eax, [eax + SOCKET.NextPtr]
or eax, eax or eax, eax
jz .error jz .error
diff16 "tetten", 0, $
cmp [eax + SOCKET.Number], ecx cmp [eax + SOCKET.Number], ecx
jne .next_socket jne .next_socket