More fixes for tcp

This commit is contained in:
Andrew Pamment 2022-07-14 20:47:50 +10:00
parent abdf9e2cfe
commit c297c13c5e
4 changed files with 8 additions and 7 deletions

View File

@ -82,6 +82,7 @@ unsigned int socket_accept(unsigned int socket, struct inet_addr *clientaddr) {
unsigned int ret;
__asm__ volatile ("int $0x30" : "=a" (ret) : "0" (40), "b" (socket), "c" (clientaddr));
while (ret == 0) {
__asm__ volatile ("int $0x30" : "=a" (ret) : "0" (23)); // yield
__asm__ volatile ("int $0x30" : "=a" (ret) : "0" (40), "b" (socket), "c" (clientaddr));
}
return ret;

View File

@ -206,6 +206,9 @@ void sched_free_task(struct task_t *this_task) {
while (ptr_vector_len(&this_task->sockets)) {
struct socket_t *s = ptr_vector_del(&this_task->sockets, 0);
if (s->status == SOCKET_STATUS_CLOSEWAIT) {
s->status = SOCKET_STATUS_CLOSE;
}
socket_close(s->serial);
}

View File

@ -242,9 +242,6 @@ void syscall_isr(struct regs *r) {
break;
case SYS_SOCK_READ:
r->eax = socket_read(r->ebx, (char *)r->ecx, r->edx);
if (r->eax == -1) {
schedule(r);
}
break;
case SYS_SOCK_WRITE:
r->eax = socket_write(r->ebx, (unsigned char *)r->ecx, r->edx);
@ -254,9 +251,6 @@ void syscall_isr(struct regs *r) {
break;
case SYS_SOCK_ACCEPT:
r->eax = (unsigned int)socket_accept(r->ebx, (struct inet_addr *)r->ecx);
if (r->eax == 0) {
schedule(r);
}
break;
case SYS_MEM_INFO:
r->eax = mem_get_info((struct mem_info *)r->ebx);

5
tcp.c
View File

@ -192,7 +192,10 @@ void tcp_process_packet(struct ether_t *ether, unsigned int dest, unsigned int s
return;
}
sock->send_payload = 1;
if (sock->status != SOCKET_STATUS_FINACK) {
if (sock->status == SOCKET_STATUS_FINACK) {
sock->status = SOCKET_STATUS_CLOSE;
socket_doclose(sock);
} else {
tcp_process_socket(sock);
}
}