forked from KolibriOS/kolibrios
TCP_send now sends correct data under all conditions
git-svn-id: svn://kolibrios.org@2893 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ad2eb55fab
commit
5133c50635
@ -784,6 +784,7 @@ SOCKET_receive_tcp:
|
|||||||
mov ecx, esi
|
mov ecx, esi
|
||||||
mov edi, edx
|
mov edi, edx
|
||||||
add eax, STREAM_SOCKET.rcv
|
add eax, STREAM_SOCKET.rcv
|
||||||
|
xor edx, edx
|
||||||
call SOCKET_ring_read
|
call SOCKET_ring_read
|
||||||
call SOCKET_ring_free
|
call SOCKET_ring_free
|
||||||
|
|
||||||
@ -1272,26 +1273,30 @@ SOCKET_ring_write:
|
|||||||
;
|
;
|
||||||
; SOCKET_ring_read
|
; SOCKET_ring_read
|
||||||
;
|
;
|
||||||
; reads the data, BUT DOES NOT CLEAR IT FROM MEMORY YET
|
; IN: eax = ring struct ptr
|
||||||
;
|
; ecx = bytes to read
|
||||||
; IN: eax = ptr to ring struct
|
; edx = offset
|
||||||
; ecx = buffer size
|
|
||||||
; edi = ptr to buffer
|
; edi = ptr to buffer
|
||||||
;
|
;
|
||||||
; OUT: ecx = number of bytes read
|
; OUT: ecx = number of bytes read (0 on error)
|
||||||
;
|
;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
SOCKET_ring_read:
|
SOCKET_ring_read:
|
||||||
|
|
||||||
DEBUGF 1,"SOCKET_ring_read: ringbuff=%x ptr=%x size=%u\n", eax, edi, ecx
|
DEBUGF 1,"SOCKET_ring_read: ringbuff=%x ptr=%x size=%u offset=%x\n", eax, edi, ecx, edx
|
||||||
|
|
||||||
cmp ecx, [eax + RING_BUFFER.size]
|
mov esi, [eax + RING_BUFFER.read_ptr]
|
||||||
|
add esi, edx ; esi = start_ptr + offset
|
||||||
|
|
||||||
|
neg edx
|
||||||
|
add edx, [eax + RING_BUFFER.size] ; edx = snd.size - offset
|
||||||
|
jle .no_data_at_all
|
||||||
|
|
||||||
|
cmp ecx, edx
|
||||||
ja .less_data
|
ja .less_data
|
||||||
|
|
||||||
.copy:
|
.copy:
|
||||||
mov esi, [eax + RING_BUFFER.read_ptr]
|
|
||||||
|
|
||||||
DEBUGF 2,"SOCKET_ring_read: %u bytes from %x to %x\n", ecx, esi, edi
|
DEBUGF 2,"SOCKET_ring_read: %u bytes from %x to %x\n", ecx, esi, edi
|
||||||
push ecx
|
push ecx
|
||||||
shr ecx, 1
|
shr ecx, 1
|
||||||
@ -1307,20 +1312,16 @@ SOCKET_ring_read:
|
|||||||
rep movsd
|
rep movsd
|
||||||
.nd:
|
.nd:
|
||||||
pop ecx
|
pop ecx
|
||||||
|
ret
|
||||||
|
|
||||||
.no_data_at_all:
|
.no_data_at_all:
|
||||||
|
DEBUGF 1,"SOCKET_ring_read_tcp: no data at all!\n", eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.less_data:
|
.less_data:
|
||||||
mov ecx, [eax + RING_BUFFER.size]
|
mov ecx, edx
|
||||||
cmp ecx, 0
|
|
||||||
jb .error
|
|
||||||
jmp .copy
|
jmp .copy
|
||||||
|
|
||||||
.error:
|
|
||||||
DEBUGF 1,"SOCKET_ring_read: ringbuff=%x error!", eax
|
|
||||||
xor ecx, ecx
|
|
||||||
ret
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------
|
||||||
;
|
;
|
||||||
|
@ -456,11 +456,13 @@ TCP_send:
|
|||||||
; edi = ptr to buffer
|
; edi = ptr to buffer
|
||||||
|
|
||||||
mov eax, [esp + 12] ; get socket ptr
|
mov eax, [esp + 12] ; get socket ptr
|
||||||
add [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number
|
|
||||||
|
|
||||||
push edx
|
push edx
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .nodata
|
jz .nodata
|
||||||
|
mov edx, [eax + TCP_SOCKET.SND_NXT]
|
||||||
|
add [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number
|
||||||
|
sub edx, [eax + TCP_SOCKET.SND_UNA]
|
||||||
add eax, STREAM_SOCKET.snd
|
add eax, STREAM_SOCKET.snd
|
||||||
call SOCKET_ring_read
|
call SOCKET_ring_read
|
||||||
.nodata:
|
.nodata:
|
||||||
|
Loading…
Reference in New Issue
Block a user