From d0105fc6d5c3937f1f3bf6d4b3a522756607591d Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Thu, 5 Apr 2012 16:23:47 +0000 Subject: [PATCH] Changes in net branch: Fixed bug in socket_ring_write concerning very big numbers. Socket_send now returns number of sent bytes. git-svn-id: svn://kolibrios.org@2573 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/net/network/socket.inc | 36 ++++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/kernel/branches/net/network/socket.inc b/kernel/branches/net/network/socket.inc index e44edee5c4..1fe20f350b 100644 --- a/kernel/branches/net/network/socket.inc +++ b/kernel/branches/net/network/socket.inc @@ -799,9 +799,10 @@ SOCKET_send_udp: DEBUGF 1,"SOCKET_send: UDP\n" + mov [esp+32], ecx call UDP_output - - mov [esp+32], eax + cmp eax, -1 + je s_error ret @@ -813,11 +814,13 @@ SOCKET_send_tcp: push eax add eax, STREAM_SOCKET.snd call SOCKET_ring_write + mov [esp+32], ecx pop eax - call TCP_output + test ecx, ecx + jz s_error - mov [esp+32], eax + call TCP_output ret @@ -826,19 +829,22 @@ SOCKET_send_ip: DEBUGF 1,"type: IP\n" + mov [esp+32], ecx call IPv4_output_raw - - mov [esp+32], eax + cmp eax, -1 + je s_error ret + align 4 SOCKET_send_icmp: DEBUGF 1,"SOCKET_send: ICMP\n" + mov [esp+32], ecx call ICMP_output_raw - - mov [esp+32], eax + cmp eax, -1 + je s_error ret @@ -1136,6 +1142,7 @@ SOCKET_ring_write: DEBUGF 1,"SOCKET_ring_write: ringbuff=%x ptr=%x size=%u\n", eax, esi, ecx add [eax + RING_BUFFER.size], ecx + jc .way_too_large cmp [eax + RING_BUFFER.size], SOCKET_MAXDATA ja .too_large @@ -1174,14 +1181,21 @@ SOCKET_ring_write: sub [eax + RING_BUFFER.size], SOCKET_MAXDATA sub ecx, [eax + RING_BUFFER.size] mov [eax + RING_BUFFER.size], SOCKET_MAXDATA + ja .copy - test ecx, ecx - jnz .copy - + .full: DEBUGF 2,"SOCKET_ring_write: ring buffer is full!\n" xor ecx, ecx ret + .way_too_large: + sub [eax + RING_BUFFER.size], ecx + mov ecx, SOCKET_MAXDATA + sub ecx, [eax + RING_BUFFER.size] + ja .copy + jmp .full + + ;----------------------------------------------------------------- ;