net: Handle signals, disconnects while waiting to recv in tcp

This commit is contained in:
K. Lange 2023-04-18 19:39:22 +09:00
parent b8b69255e3
commit 0db8e34627

View File

@ -705,7 +705,14 @@ static long sock_tcp_recv(sock_t * sock, struct msghdr * msg, int flags) {
if (!sock->rx_queue->length && sock->nonblocking) return -EAGAIN;
while (!sock->rx_queue->length) {
process_wait_nodes((process_t *)this_core->current_process, (fs_node_t*[]){(fs_node_t*)sock,NULL}, 200);
int r = process_wait_nodes((process_t *)this_core->current_process, (fs_node_t*[]){(fs_node_t*)sock,NULL}, 200);
if (r == -EINTR) return -ERESTARTSYS;
if (!sock->rx_queue->length) {
if (sock->priv[1] == 3) {
/* Socket was closed while waiting */
return 0;
}
}
}
char * packet = net_sock_get(sock);