From e3b7958faa27c82c5b3e8d0e0271ad610cf61e6d Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sun, 30 Jun 2013 23:08:53 +0000 Subject: [PATCH] SOCKET_receive, return immediately when there is no data and SS_CANTRECVMORE is set. Downloader: make better use of blocking sockets. git-svn-id: svn://kolibrios.org@3737 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/network/socket.inc | 3 +++ kernel/trunk/network/tcp_subr.inc | 2 +- kernel/trunk/network/udp.inc | 1 - programs/network/downloader/downloader.asm | 14 ++------------ 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/kernel/trunk/network/socket.inc b/kernel/trunk/network/socket.inc index abfc9a78f3..1c107a48c5 100644 --- a/kernel/trunk/network/socket.inc +++ b/kernel/trunk/network/socket.inc @@ -871,6 +871,9 @@ SOCKET_receive: test edi, MSG_DONTWAIT jnz .return_err + test [eax + SOCKET.state], SS_CANTRCVMORE + jnz .return_err + ; test [eax + SOCKET.options], SO_NONBLOCK ; jnz .return_err diff --git a/kernel/trunk/network/tcp_subr.inc b/kernel/trunk/network/tcp_subr.inc index abc5b198a5..2db7d1a3d9 100644 --- a/kernel/trunk/network/tcp_subr.inc +++ b/kernel/trunk/network/tcp_subr.inc @@ -190,7 +190,7 @@ TCP_close: ;;; TODO: update slow start threshold call SOCKET_is_disconnected - call SOCKET_free +;; call SOCKET_free ret diff --git a/kernel/trunk/network/udp.inc b/kernel/trunk/network/udp.inc index 47d6faf424..d50bb164cb 100644 --- a/kernel/trunk/network/udp.inc +++ b/kernel/trunk/network/udp.inc @@ -116,7 +116,6 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size ; ;----------------------------------------------------------------- align 4 -diff16 "UDP packetgfgfgfgfs", 0, $ UDP_input: DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: size=%u\n", ecx diff --git a/programs/network/downloader/downloader.asm b/programs/network/downloader/downloader.asm index 1f07dc89b0..65c32bb3a7 100644 --- a/programs/network/downloader/downloader.asm +++ b/programs/network/downloader/downloader.asm @@ -359,21 +359,14 @@ read_incoming_data: DEBUGF 1, "Reading incoming data\n" - mcall 40, EVM_STACK + EVM_BUTTON - mov eax, [buf_ptr] mov [pos], eax - .read: - mcall 23, 100 ; 1 second timeout - cmp eax, EV_BUTTON - je exit - .read_dontwait: - mcall recv, [socketnum], [pos], BUFFERSIZE, MSG_DONTWAIT + mcall recv, [socketnum], [pos], BUFFERSIZE, 0 inc eax ; -1 = error (socket closed?) jz .no_more_data dec eax ; 0 bytes... - jz .read ; timeout + jz .read DEBUGF 1, "Got chunk of %u bytes\n", eax @@ -385,9 +378,6 @@ read_incoming_data: mcall 68, 20, , [buf_ptr] ; reallocate memory block (make bigger) ; TODO: parse header and resize buffer only once pop eax - - cmp eax, BUFFERSIZE - je .read_dontwait jmp .read .no_more_data: