aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/syscall.c
diff options
context:
space:
mode:
authorMarvin Borner2020-11-20 15:58:32 +0100
committerMarvin Borner2020-11-20 15:58:32 +0100
commit5708ab26c0de8fc1be3e96a0f3f092da0938169e (patch)
treede63e635b99923a17120030317b69d57ea676d6f /kernel/features/syscall.c
parent56e33a757dee8b6c34cc1721e58d84be5f353e23 (diff)
Fixed some network race conditions
Diffstat (limited to 'kernel/features/syscall.c')
-rw-r--r--kernel/features/syscall.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c
index 3ee5a82..0328f47 100644
--- a/kernel/features/syscall.c
+++ b/kernel/features/syscall.c
@@ -97,7 +97,13 @@ void syscall_handler(struct regs *r)
break;
}
case SYS_NET_CLOSE: {
- net_close((void *)r->ebx);
+ struct socket *s = (void *)r->ebx;
+ if (s->type == S_TCP && s->state != S_CLOSED) {
+ proc_current()->state = PROC_SLEEPING;
+ proc_yield(r);
+ return;
+ }
+ r->eax = net_close(s);
break;
}
case SYS_NET_CONNECT: {
@@ -112,6 +118,7 @@ void syscall_handler(struct regs *r)
if (!net_data_available((void *)r->ebx)) {
proc_current()->state = PROC_SLEEPING;
proc_yield(r);
+ return;
}
r->eax = net_receive((void *)r->ebx, (void *)r->ecx, r->edx);
break;