cpu: change _cpu()->thread calls to current_thread() to fix smp race

This commit is contained in:
Matheus
2024-09-15 17:47:26 -03:00
parent d1c0f2a5fd
commit e058d62261
65 changed files with 196 additions and 190 deletions
+5 -5
View File
@@ -357,8 +357,8 @@ static int localsock_send(socket_t *socket, sockdesc_t *sockdesc) {
localsocket_t *peer = pair->client == localsocket ? pair->server : pair->client;
if (peer == NULL) {
if (_cpu()->thread->proc && (sockdesc->flags & SOCKET_SEND_FLAGS_NOSIGNAL) == 0)
signal_signalproc(_cpu()->thread->proc, SIGPIPE);
if (current_thread()->proc && (sockdesc->flags & SOCKET_SEND_FLAGS_NOSIGNAL) == 0)
signal_signalproc(current_thread()->proc, SIGPIPE);
error = EPIPE;
goto leave;
@@ -873,9 +873,9 @@ static int localsock_bind(socket_t *socket, sockaddr_t *addr, cred_t *cred) {
refnode = *path == '/' ? sched_getroot() : sched_getcwd();
vattr_t attr = {
.mode = _cpu()->thread->proc ? UMASK(0777) : 0644,
.gid = _cpu()->thread->proc ? _cpu()->thread->proc->cred.gid : 0,
.uid = _cpu()->thread->proc ? _cpu()->thread->proc->cred.uid : 0
.mode = current_thread()->proc ? UMASK(0777) : 0644,
.gid = current_thread()->proc ? current_thread()->proc->cred.gid : 0,
.uid = current_thread()->proc ? current_thread()->proc->cred.uid : 0
};
vnode_t *vnode;
+5 -5
View File
@@ -838,7 +838,7 @@ typedef struct {
} __attribute__((packed)) synoptions_t;
__attribute__((noreturn)) static void tcp_worker() {
tcpworker_t *self = _cpu()->thread->kernelarg;
tcpworker_t *self = current_thread()->kernelarg;
ipv4pseudoheader_t ipv4;
int tasktype;
tcb_t *tcb = NULL;
@@ -1254,8 +1254,8 @@ static int tcp_send(socket_t *socket, sockdesc_t *sockdesc) {
MUTEX_ACQUIRE(&tcb->mutex, false);
if (tcb->reset) {
if (_cpu()->thread->proc)
signal_signalproc(_cpu()->thread->proc, SIGPIPE);
if (current_thread()->proc)
signal_signalproc(current_thread()->proc, SIGPIPE);
error = ECONNRESET;
goto leave;
}
@@ -1272,8 +1272,8 @@ static int tcp_send(socket_t *socket, sockdesc_t *sockdesc) {
poll_leave(&polldesc);
poll_destroydesc(&polldesc);
if (_cpu()->thread->proc && (sockdesc->flags & SOCKET_SEND_FLAGS_NOSIGNAL) == 0)
signal_signalproc(_cpu()->thread->proc, SIGPIPE);
if (current_thread()->proc && (sockdesc->flags & SOCKET_SEND_FLAGS_NOSIGNAL) == 0)
signal_signalproc(current_thread()->proc, SIGPIPE);
error = EPIPE;
goto leave;
+1 -1
View File
@@ -139,7 +139,7 @@ static int vionet_sendpacket(netdev_t *internal, netdesc_t desc, mac_t targetmac
VIO_QUEUE_DRV_RING(&netdev->txqueue)[driveridx % netdev->txqueue.size] = idx;
sched_preparesleep(false);
netdev->txwait[idx] = _cpu()->thread;
netdev->txwait[idx] = current_thread();
*netdev->txqueue.notify = 0;
spinlock_release(&netdev->txlock);