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
This commit is contained in:
hidnplayr 2013-06-30 23:08:53 +00:00
parent 27d4f503b4
commit e3b7958faa
4 changed files with 6 additions and 14 deletions

View File

@ -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

View File

@ -190,7 +190,7 @@ TCP_close:
;;; TODO: update slow start threshold
call SOCKET_is_disconnected
call SOCKET_free
;; call SOCKET_free
ret

View File

@ -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

View File

@ -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: