forked from KolibriOS/kolibrios
Socket_receive: return -1 when socket is closed.
git-svn-id: svn://kolibrios.org@3565 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a35c1d0445
commit
8e107a1443
@ -516,7 +516,7 @@ align 4
|
|||||||
btr ecx, eax ; сбрасываем проверяемый бит маски
|
btr ecx, eax ; сбрасываем проверяемый бит маски
|
||||||
; переходим на обработчик этого (eax) бита
|
; переходим на обработчик этого (eax) бита
|
||||||
cmp eax, 10
|
cmp eax, 10
|
||||||
jae .loop ; eax=[10..31], ignored (event 10...32)
|
jae .loop ; eax=[10..31], ignored (event 11...32)
|
||||||
|
|
||||||
cmp eax, 3
|
cmp eax, 3
|
||||||
je .loop ; eax=3, ignored (event 4)
|
je .loop ; eax=3, ignored (event 4)
|
||||||
|
@ -772,7 +772,10 @@ SOCKET_receive:
|
|||||||
call SOCKET_num_to_ptr
|
call SOCKET_num_to_ptr
|
||||||
jz s_error
|
jz s_error
|
||||||
|
|
||||||
jmp [eax + SOCKET.rcv_proc]
|
call [eax + SOCKET.rcv_proc]
|
||||||
|
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
@ -792,10 +795,10 @@ SOCKET_receive_dgram:
|
|||||||
cmp ecx, ebx
|
cmp ecx, ebx
|
||||||
ja .too_small
|
ja .too_small
|
||||||
|
|
||||||
|
push 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
|
||||||
mov [esp+32+4], ecx ; return number of bytes copied
|
|
||||||
|
|
||||||
; copy the data
|
; copy the data
|
||||||
shr ecx, 1
|
shr ecx, 1
|
||||||
@ -812,16 +815,20 @@ SOCKET_receive_dgram:
|
|||||||
.nd:
|
.nd:
|
||||||
|
|
||||||
call kernel_free ; remove the packet
|
call kernel_free ; remove the packet
|
||||||
|
pop eax
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.too_small:
|
.too_small:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: Buffer too small\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: Buffer too small\n"
|
||||||
jmp s_error
|
.fail:
|
||||||
|
mov eax, -1
|
||||||
|
ret
|
||||||
|
|
||||||
.block:
|
.block:
|
||||||
test [eax + SOCKET.options], SO_NONBLOCK
|
test [eax + SOCKET.options], SO_NONBLOCK
|
||||||
jnz s_error
|
jnz .fail
|
||||||
|
|
||||||
call SOCKET_block
|
call SOCKET_block
|
||||||
jmp .loop
|
jmp .loop
|
||||||
@ -866,12 +873,11 @@ SOCKET_receive_stream:
|
|||||||
call SOCKET_ring_read
|
call SOCKET_ring_read
|
||||||
call SOCKET_ring_free
|
call SOCKET_ring_free
|
||||||
|
|
||||||
mov [esp+32], ecx ; return number of bytes copied
|
mov eax, ecx ; return number of bytes copied
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.peek:
|
.peek:
|
||||||
mov ecx, [eax + STREAM_SOCKET.rcv + RING_BUFFER.size]
|
mov eax, [eax + STREAM_SOCKET.rcv + RING_BUFFER.size]
|
||||||
mov [esp+32], ecx ; return number of bytes available
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.block:
|
.block:
|
||||||
@ -882,8 +888,15 @@ SOCKET_receive_stream:
|
|||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
.return0:
|
.return0:
|
||||||
xor ecx, ecx
|
test [eax + SOCKET.options], SS_CANTRCVMORE
|
||||||
mov [esp+32], ecx
|
jz .ok
|
||||||
|
|
||||||
|
xor eax, eax
|
||||||
|
dec eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.ok:
|
||||||
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -2261,6 +2274,8 @@ SOCKET_cant_recv_more:
|
|||||||
|
|
||||||
or [eax + SOCKET.options], SS_CANTRCVMORE
|
or [eax + SOCKET.options], SS_CANTRCVMORE
|
||||||
|
|
||||||
|
call SOCKET_notify
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -2280,5 +2295,8 @@ SOCKET_cant_send_more:
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_cant_send_more: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_cant_send_more: %x\n", eax
|
||||||
|
|
||||||
or [eax + SOCKET.options], SS_CANTSENDMORE
|
or [eax + SOCKET.options], SS_CANTSENDMORE
|
||||||
|
mov [eax + SOCKET.snd_proc], s_error
|
||||||
|
|
||||||
|
call SOCKET_notify
|
||||||
|
|
||||||
ret
|
ret
|
Loading…
Reference in New Issue
Block a user