]> git.pond.sub.org Git - empserver/commitdiff
Make empth_name() and empth_set_name() take a thread argument
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 11 Sep 2008 23:25:34 +0000 (19:25 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 11 Sep 2008 23:25:34 +0000 (19:25 -0400)
include/empthread.h
src/lib/empthread/lwp.c
src/lib/empthread/ntthread.c
src/lib/empthread/pthread.c
src/lib/player/login.c
src/lib/subs/journal.c

index 239824e887891d421d94270d1760348a1db9ec48..4d039f3e761807674e9b171849ad4a04dfe8f42a 100644 (file)
@@ -128,14 +128,14 @@ empth_t *empth_create(void (*entry)(void *),
 empth_t *empth_self(void);
 
 /*
- * Return the name of the current thread.
+ * Return the name THREAD.
  */
-char *empth_name(void);
+char *empth_name(empth_t *thread);
 
 /*
- * Sets the name of the current thread.
+ * Set the name of THREAD to NAME.
  */
-void empth_set_name(char *);
+void empth_set_name(empth_t *thread, char *name);
 
 /*
  * Terminate the current thread.
index 73fc116aa472545513286c35ec4b40c2b55918c0..838bb6b9fb9ddcb376cde13d8bfa67e40508e42f 100644 (file)
@@ -75,15 +75,15 @@ empth_self(void)
 }
 
 char *
-empth_name(void)
+empth_name(empth_t *thread)
 {
-    return lwpName(LwpCurrent);
+    return lwpName(thread);
 }
 
 void
-empth_set_name(char *name)
+empth_set_name(empth_t *thread, char *name)
 {
-    lwpSetName(LwpCurrent, name);
+    lwpSetName(thread, name);
 }
 
 void
index e7d4886646a30e45e81311b1590b4b7b16544c05..4799b0311644b33254ac0c33fb666e80ce573c08 100644 (file)
@@ -490,9 +490,9 @@ empth_self(void)
  * empth_name
  */
 char *
-empth_name(void)
+empth_name(empth_t *thread)
 {
-    return empth_self()->szName;
+    return thread->szName;
 }
 
 /************************
@@ -500,11 +500,9 @@ empth_name(void)
  * Set the thread name
  */
 void
-empth_set_name(char *name)
+empth_set_name(empth_t *thread, char *name)
 {
-    empth_t *pThread = TlsGetValue(dwTLSIndex);
-
-    strncpy(pThread->szName, name, sizeof(pThread->szName) - 1);
+    strncpy(thread->szName, name, sizeof(thread->szName) - 1);
 }
 
 /************************
index 689868b21c2bf503ee04e7f83b6f83a63ccdf23e..36abfb7a9a616690dcb2d055a1a183073ba5959c 100644 (file)
@@ -248,22 +248,17 @@ empth_self(void)
 }
 
 char *
-empth_name(void)
+empth_name(empth_t *thread)
 {
-    return empth_self()->name;
+    return thread->name;
 }
 
 void
-empth_set_name(char *name)
+empth_set_name(empth_t *thread, char *name)
 {
-    empth_t *ctx_ptr;
-    
-    ctx_ptr = pthread_getspecific(ctx_key);
-
-    if (ctx_ptr->name != NULL)
+    if (thread->name)
        free(ctx_ptr->name);
-
-    ctx_ptr->name = strdup(name);
+    thread->name = strdup(name);
 }
 
 void
index 3b0148a8d28bde9cd47b2334c1837d14a78edb8a..2fe4442238e56a0ff4d3af9ecdb4f5a33a119340 100644 (file)
@@ -344,7 +344,7 @@ play_cmd(void)
        return RET_FAIL;
     }
     snprintf(buf, sizeof(buf), "Play#%d", player->cnum);
-    empth_set_name(buf);
+    empth_set_name(empth_self(), buf);
     logerror("%s logged in as country #%d", praddr(player), player->cnum);
     pr_id(player, C_INIT, "%d\n", CLIENTPROTO);
     player_main(player);
index fcaa752c58f7e1b225433d61e8da19f782af5081..eeafbef2da8e680139b021510919a6dc9518f457 100644 (file)
@@ -83,7 +83,8 @@ journal_entry(char *fmt, ...)
 
     if (journal) {
        time(&now);
-       fprintf(journal, "%.24s %10.10s:", ctime(&now), empth_name());
+       fprintf(journal, "%.24s %10.10s:",
+               ctime(&now), empth_name(empth_self()));
        
        va_start(ap, fmt);
        vsnprintf(buf, sizeof(buf) - 1, fmt, ap);