client__pollin: read as much as possible; client__pollout: do processing

This commit is contained in:
root 2025-05-17 08:10:55 +00:00
parent 8ab750ba97
commit 484d81baa8
3 changed files with 149 additions and 92 deletions

17
main.s
View file

@ -30,11 +30,18 @@ SHUT_RDWR equ 2
;STATE_READING equ 0
;STATE_WRITING equ 1
; offsets into client struct
OFFSET_CLIENT_FD equ 0
OFFSET_CLIENT_STATE equ 4
OFFSET_CLIENT_BUFFER_LEN equ 5
OFFSET_CLIENT_BUFFER equ 6
pollfd_size equ 4 + 2 + 2 ; $ man 2 poll
pollfds_capacity equ 100
; fd, state, line_len, buffer_len, uri_len, buffer, uri
client_size equ 4 + 4 + 255 + 255
client_buffer_size equ 255
; fd, state, buffer_len, buffer
client_size equ 4 + 2 + client_buffer_size
clients_capacity equ pollfds_capacity - 1
SECTION .data
@ -109,7 +116,7 @@ scan__found__client:
mov r10w, r14w
and r10w, POLLERR | POLLNVAL
cmp r10w, 0
jne _client__error
jne _client__error_or_eof
mov r10w, r14w
and r10w, POLLIN
@ -125,7 +132,7 @@ scan__found__client:
add r15, 1
jmp scan__loop
_client__error:
_client__error_or_eof:
mov rdi, r12
call clients__remove
@ -142,7 +149,7 @@ _client__pollin:
mov rdx, r15
call client__pollin
cmp rax, 0
jle _client__error
jle _client__error_or_eof
add r15, rax
jmp scan__loop