]> git.feebdaed.xyz Git - socialize.git/commitdiff
fix lock
authorseantywork <seantywork@gmail.com>
Mon, 17 Mar 2025 06:41:16 +0000 (15:41 +0900)
committerseantywork <seantywork@gmail.com>
Mon, 17 Mar 2025 06:41:16 +0000 (15:41 +0900)
include/socialize/ctl.h
src/ctl.c
src/sock/sock.c

index 90235578ba10bfe4d7270d2edac267bc387852c2..219cc826b58cfbd8b7965e8f98c4015625272a5c 100644 (file)
@@ -65,9 +65,9 @@ void ctx_read_packet(struct HUB_PACKET* hp);
 
 void spinlock_init(struct spinlock* spinlock);
 
-void pthread_mutext_lock(struct spinlock* spinlock);
+void spinlock_lock(struct spinlock* spinlock);
 
-void pthread_mutext_unlock(struct spinlock* spinlock);
+void spinlock_unlock(struct spinlock* spinlock);
 
 
 #endif
\ No newline at end of file
index 822442c934b6cdc8b12e84c5506e18d59604af16..712cc16bbb03c53440ff4a43d0893d112ff4fcb0 100644 (file)
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -254,13 +254,13 @@ struct SOCK_CONTEXT* get_sockctx_by_fd(int fd){
 
     struct SOCK_CONTEXT_LOCK* ctxlock;
 
-    pthread_mutext_lock(&SOCK_CTL.slock);
+    pthread_mutex_lock(&SOCK_CTL.slock);
 
     if(SOCK_CTL.in_use == 0){
 
         printf("sockctl not in use\n");
 
-        pthread_mutext_unlock(&SOCK_CTL.slock);
+        pthread_mutex_unlock(&SOCK_CTL.slock);
 
         return NULL;
     }
@@ -271,7 +271,7 @@ struct SOCK_CONTEXT* get_sockctx_by_fd(int fd){
 
     ctxlock = SOCK_CTL.SOCK_CTX_LOCK[i];
 
-    pthread_mutext_unlock(&SOCK_CTL.slock);
+    pthread_mutex_unlock(&SOCK_CTL.slock);
 
     pthread_mutex_lock(&ctxlock->lock);
 
@@ -513,13 +513,13 @@ int calloc_sockctx(int fd){
 
     struct SOCK_CONTEXT_LOCK* ctxlock = NULL;
 
-    pthread_mutext_lock(&SOCK_CTL.slock);
+    pthread_mutex_lock(&SOCK_CTL.slock);
 
     if(SOCK_CTL.in_use == 0){
 
         printf("sockctl not in use\n");
 
-        pthread_mutext_unlock(&SOCK_CTL.slock);
+        pthread_mutex_unlock(&SOCK_CTL.slock);
 
         return -1;
     }
@@ -530,7 +530,7 @@ int calloc_sockctx(int fd){
 
     ctxlock = SOCK_CTL.SOCK_CTX_LOCK[i];
 
-    pthread_mutext_unlock(&SOCK_CTL.slock);
+    pthread_mutex_unlock(&SOCK_CTL.slock);
 
     pthread_mutex_lock(&ctxlock->lock);
 
@@ -568,13 +568,13 @@ int free_sockctx(int fd, int memfree){
 
     struct SOCK_CONTEXT_LOCK* ctxlock = NULL;
 
-    pthread_mutext_lock(&SOCK_CTL.slock);
+    pthread_mutex_lock(&SOCK_CTL.slock);
 
     if(SOCK_CTL.in_use == 0){
 
         printf("sockctl not in use\n");
 
-        pthread_mutext_unlock(&SOCK_CTL.slock);
+        pthread_mutex_unlock(&SOCK_CTL.slock);
 
         return -1;
     }
@@ -586,7 +586,7 @@ int free_sockctx(int fd, int memfree){
 
     ctxlock = SOCK_CTL.SOCK_CTX_LOCK[i];
 
-    pthread_mutext_unlock(&SOCK_CTL.slock);
+    pthread_mutex_unlock(&SOCK_CTL.slock);
 
     pthread_mutex_lock(&ctxlock->lock);
 
@@ -941,11 +941,11 @@ void spinlock_init(struct spinlock* spinlock) {
     atomic_store(&spinlock->locked, 0);
 }
 
-void pthread_mutext_lock(struct spinlock* spinlock) {
+void spinlock_lock(struct spinlock* spinlock) {
     while (!atomic_compare_exchange(&spinlock->locked, 0, 1)) {
     }
 }
 
-void pthread_mutext_unlock(struct spinlock* spinlock) {
+void spinlock_unlock(struct spinlock* spinlock) {
     atomic_store(&spinlock->locked, 0);
 }
index b463cb1646a47935a2628f36c4c336cfb1adf7ca..945dd8b864b1226ac7406ce58e33974204991250 100644 (file)
@@ -34,7 +34,7 @@ int init_all(){
 
     SOCK_CTL.in_use = 1;
 
-    spinlock_init(&SOCK_CTL.slock);
+    pthread_mutex_init(&SOCK_CTL.slock, NULL);
 
     SOCK_CTL.size = MAX_CONN;
 
@@ -59,7 +59,7 @@ int init_all(){
 
 int free_all(){
 
-    pthread_mutext_lock(&SOCK_CTL.slock);
+    pthread_mutex_lock(&SOCK_CTL.slock);
 
     SOCK_CTL.in_use = 0;
 
@@ -75,7 +75,7 @@ int free_all(){
 
     free(SOCK_CTL.SOCK_CTX_LOCK);
 
-    pthread_mutext_unlock(&SOCK_CTL.slock);
+    pthread_mutex_unlock(&SOCK_CTL.slock);
 }
 
 void sock_listen_and_serve(void* varg){