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 test edi, MSG_DONTWAIT
jnz .return_err jnz .return_err
test [eax + SOCKET.state], SS_CANTRCVMORE
jnz .return_err
; test [eax + SOCKET.options], SO_NONBLOCK ; test [eax + SOCKET.options], SO_NONBLOCK
; jnz .return_err ; jnz .return_err

View File

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

View File

@ -116,7 +116,6 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
align 4 align 4
diff16 "UDP packetgfgfgfgfs", 0, $
UDP_input: UDP_input:
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: size=%u\n", ecx 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" DEBUGF 1, "Reading incoming data\n"
mcall 40, EVM_STACK + EVM_BUTTON
mov eax, [buf_ptr] mov eax, [buf_ptr]
mov [pos], eax mov [pos], eax
.read: .read:
mcall 23, 100 ; 1 second timeout mcall recv, [socketnum], [pos], BUFFERSIZE, 0
cmp eax, EV_BUTTON
je exit
.read_dontwait:
mcall recv, [socketnum], [pos], BUFFERSIZE, MSG_DONTWAIT
inc eax ; -1 = error (socket closed?) inc eax ; -1 = error (socket closed?)
jz .no_more_data jz .no_more_data
dec eax ; 0 bytes... dec eax ; 0 bytes...
jz .read ; timeout jz .read
DEBUGF 1, "Got chunk of %u bytes\n", eax 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) mcall 68, 20, , [buf_ptr] ; reallocate memory block (make bigger)
; TODO: parse header and resize buffer only once ; TODO: parse header and resize buffer only once
pop eax pop eax
cmp eax, BUFFERSIZE
je .read_dontwait
jmp .read jmp .read
.no_more_data: .no_more_data: