Timeout for HTTP library
git-svn-id: svn://kolibrios.org@4206 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
0c94d22080
commit
3ae5249709
@ -19,6 +19,7 @@
|
||||
|
||||
URLMAXLEN = 65535
|
||||
BUFFERSIZE = 4096
|
||||
TIMEOUT = 1000 ; in 1/100 s
|
||||
|
||||
__DEBUG__ = 1
|
||||
__DEBUG_LEVEL__ = 1
|
||||
@ -66,6 +67,12 @@ macro HTTP_init_buffer buffer, socketnum {
|
||||
mov [eax + http_msg.header_length], 0
|
||||
mov [eax + http_msg.content_length], 0
|
||||
mov [eax + http_msg.content_received], 0
|
||||
|
||||
push eax ebp
|
||||
mov ebp, eax
|
||||
mcall 29, 9
|
||||
mov [ebp + http_msg.timestamp], eax
|
||||
pop ebp eax
|
||||
}
|
||||
|
||||
section '.flat' code readable align 16
|
||||
@ -387,6 +394,7 @@ endl
|
||||
DEBUGF 1, "Request has been sent to server.\n"
|
||||
|
||||
HTTP_init_buffer [buffer], [socketnum]
|
||||
|
||||
; mov eax, [buffer]
|
||||
|
||||
ret ; return buffer ptr
|
||||
@ -423,6 +431,11 @@ proc HTTP_process identifier ;//////////////////////////////////////////////////
|
||||
je .check_socket
|
||||
DEBUGF 1, "Received %u bytes\n", eax
|
||||
|
||||
push eax
|
||||
mcall 29, 9
|
||||
mov [ebp + http_msg.timestamp], eax
|
||||
pop eax
|
||||
|
||||
; Update pointers
|
||||
mov edi, [ebp + http_msg.write_ptr]
|
||||
add [ebp + http_msg.write_ptr], eax
|
||||
@ -712,34 +725,36 @@ proc HTTP_process identifier ;//////////////////////////////////////////////////
|
||||
|
||||
.check_socket:
|
||||
cmp ebx, EWOULDBLOCK
|
||||
je .need_more_data
|
||||
DEBUGF 1, "ERROR: socket error %u\n", ebx
|
||||
jne .socket_error
|
||||
|
||||
or [ebp + http_msg.flags], FLAG_SOCKET_ERROR
|
||||
and [ebp + http_msg.flags], not FLAG_CONNECTED
|
||||
mcall close, [ebp + http_msg.socket]
|
||||
.connection_closed:
|
||||
popa
|
||||
xor eax, eax
|
||||
ret
|
||||
mcall 29, 9
|
||||
sub eax, TIMEOUT
|
||||
cmp eax, [ebp + http_msg.timestamp]
|
||||
ja .need_more_data
|
||||
DEBUGF 1, "ERROR: timeout\n"
|
||||
or [ebp + http_msg.flags], FLAG_TIMEOUT_ERROR
|
||||
jmp .disconnect
|
||||
|
||||
.invalid_header:
|
||||
pop eax
|
||||
DEBUGF 1, "ERROR: invalid header\n"
|
||||
or [ebp + http_msg.flags], FLAG_INVALID_HEADER
|
||||
and [ebp + http_msg.flags], not FLAG_CONNECTED
|
||||
mcall close, [ebp + http_msg.socket]
|
||||
popa
|
||||
xor eax, eax
|
||||
ret
|
||||
jmp .disconnect
|
||||
|
||||
.no_ram_pop:
|
||||
pop eax
|
||||
.no_ram:
|
||||
DEBUGF 1, "ERROR: out of RAM\n"
|
||||
or [ebp + http_msg.flags], FLAG_NO_RAM
|
||||
jmp .disconnect
|
||||
|
||||
.socket_error:
|
||||
DEBUGF 1, "ERROR: socket error %u\n", ebx
|
||||
or [ebp + http_msg.flags], FLAG_SOCKET_ERROR
|
||||
.disconnect:
|
||||
and [ebp + http_msg.flags], not FLAG_CONNECTED
|
||||
mcall close, [ebp + http_msg.socket]
|
||||
.connection_closed:
|
||||
popa
|
||||
xor eax, eax
|
||||
ret
|
||||
|
@ -24,6 +24,7 @@ FLAG_CONNECTED = 1 shl 5
|
||||
FLAG_INVALID_HEADER = 1 shl 16
|
||||
FLAG_NO_RAM = 1 shl 17
|
||||
FLAG_SOCKET_ERROR = 1 shl 18
|
||||
FLAG_TIMEOUT_ERROR = 1 shl 19
|
||||
|
||||
struc http_msg {
|
||||
.socket dd ?
|
||||
@ -31,7 +32,7 @@ struc http_msg {
|
||||
.write_ptr dd ?
|
||||
.buffer_length dd ?
|
||||
.chunk_ptr dd ?
|
||||
|
||||
.timestamp dd ?
|
||||
.status dd ?
|
||||
.header_length dd ?
|
||||
.content_length dd ?
|
||||
|
Loading…
Reference in New Issue
Block a user