From 1fc22f7bcefeff1b4ee7145c92d81d4c70fe26e4 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Tue, 9 Apr 2013 10:47:23 +0000 Subject: [PATCH] Experimental support for MSG_PEEK and MSG_DONTWAIT in SOCKET_receive_stream. git-svn-id: svn://kolibrios.org@3459 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/net/network/socket.inc | 13 +++++++++++++ kernel/branches/net/network/stack.inc | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/kernel/branches/net/network/socket.inc b/kernel/branches/net/network/socket.inc index 0a37a266eb..98fdbd2167 100644 --- a/kernel/branches/net/network/socket.inc +++ b/kernel/branches/net/network/socket.inc @@ -848,12 +848,20 @@ SOCKET_receive_stream: DEBUGF 1,"SOCKET_receive: STREAM\n" + mov ebx, edi mov ecx, esi mov edi, edx xor edx, edx + + test ebx, MSG_DONTWAIT + jnz .dontwait .loop: cmp [eax + STREAM_SOCKET.rcv + RING_BUFFER.size], 0 je .block + .dontwait: + test ebx, MSG_PEEK + jnz .peek + add eax, STREAM_SOCKET.rcv call SOCKET_ring_read call SOCKET_ring_free @@ -861,6 +869,11 @@ SOCKET_receive_stream: mov [esp+32], ecx ; return number of bytes copied ret + .peek: + mov ecx, [eax + STREAM_SOCKET.rcv + RING_BUFFER.size] + mov [esp+32], ecx ; return number of bytes available + ret + .block: test [eax + SOCKET.options], SO_NONBLOCK jnz s_error diff --git a/kernel/branches/net/network/stack.inc b/kernel/branches/net/network/stack.inc index d418d52701..f8bf99c133 100644 --- a/kernel/branches/net/network/stack.inc +++ b/kernel/branches/net/network/stack.inc @@ -83,6 +83,10 @@ SO_BINDTODEVICE = 1 shl 9 SO_BLOCK = 1 shl 10 ; TO BE REMOVED SO_NONBLOCK = 1 shl 31 +; Socket flags for user calls +MSG_PEEK = 0x02 +MSG_DONTWAIT = 0x40 + ; Socket level SOL_SOCKET = 0 @@ -264,6 +268,12 @@ stack_handler: cmp [NET_RUNNING], 0 je .exit + cmp [UDP_PACKETS_TX], 50 + jb @f + DEBUGF 1, "\n\nCRAP!\n\n" + jmp $ + @@: + ; Test for 10ms tick mov eax, [timer_ticks] cmp eax, [net_10ms]