]> git.pond.sub.org Git - empserver/commitdiff
Rename play_lock back to update_lock
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 27 Mar 2012 18:06:35 +0000 (20:06 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 26 Apr 2012 18:08:57 +0000 (20:08 +0200)
It was renamed to play_lock because it synchronized not just updates
but also shutdown.  Since the previous commit, it again only
synchronizes updates.  Rename it back.

Also move its initialization next to shutdown_lock's.

include/server.h
src/lib/player/dispatch.c
src/server/main.c
src/server/update.c

index 0729d554233ccd7d91102c6c35b74000bfb02759..fea0a080c166f59c7d3180731240a69df9f0dd0e 100644 (file)
@@ -38,7 +38,7 @@
 #define UPDATE_TIME_LEN 16
 
 extern int shutdown_pending;
-extern empth_rwlock_t *play_lock;
+extern empth_rwlock_t *update_lock;
 extern empth_rwlock_t *shutdown_lock;
 extern int update_running;
 extern time_t update_time[UPDATE_TIME_LEN];
index 73f5051c15bae6543cc7e374785bb3e1b839d27e..c2de9a57e877f562df5efde475e13e0f67b7062e 100644 (file)
@@ -87,7 +87,7 @@ dispatch(char *buf, char *redir)
     player->may_sleep = command->c_flags & C_MOD
        ? PLAYER_SLEEP_ON_INPUT : PLAYER_SLEEP_FREELY;
     player->command = command;
-    empth_rwlock_rdlock(play_lock);
+    empth_rwlock_rdlock(update_lock);
     if (redir) {
        prredir(redir);
        uprnf(buf);
@@ -109,7 +109,7 @@ dispatch(char *buf, char *redir)
        CANT_REACH();
        break;
     }
-    empth_rwlock_unlock(play_lock);
+    empth_rwlock_unlock(update_lock);
     player->command = NULL;
     if (player->may_sleep != PLAYER_SLEEP_NEVER || !io_eof(player->iop))
        player->may_sleep = PLAYER_SLEEP_FREELY;
index 267de1cdb37d75cb7e6173065d64c704ff3574c1..f67d9b25c1d5213c8e1eca5b41c5369458541525 100644 (file)
@@ -78,7 +78,7 @@ static void loc_NTInit(void);
  * Lock to synchronize player threads with update.
  * Update holds it exclusive, commands hold it shared.
  */
-empth_rwlock_t *play_lock;
+empth_rwlock_t *update_lock;
 /*
  * Lock to synchronize player threads with shutdown.
  * Shutdown holds it exclusive, player threads in state PS_PLAYING
@@ -380,8 +380,9 @@ start_server(int flags)
     if (journal_startup() < 0)
        exit(1);
 
+    update_lock = empth_rwlock_create("Update");
     shutdown_lock = empth_rwlock_create("Shutdown");
-    if (!shutdown_lock)
+    if (!update_lock || !shutdown_lock)
        exit_nomem();
 
     market_init();
index dd6f2acb39c4e929b411edc5c26fdc08e7add4d3..5afdb9ab7d12dfb23157a6863eedaa8a9dfdfe1a 100644 (file)
@@ -74,10 +74,6 @@ update_init(void)
     if (update_get_schedule() < 0)
        exit(1);
 
-    play_lock = empth_rwlock_create("Update");
-    if (!play_lock)
-       exit_nomem();
-
     dp = player_new(-1);
     if (!dp)
        exit_nomem();
@@ -207,17 +203,17 @@ update_run(void)
            empth_wakeup(p->proc);
        }
     }
-    empth_rwlock_wrlock(play_lock);
+    empth_rwlock_wrlock(update_lock);
     if (*pre_update_hook) {
        if (run_hook(pre_update_hook, "pre-update")) {
-           empth_rwlock_unlock(play_lock);
+           empth_rwlock_unlock(update_lock);
            return;
        }
     }
     update_running = 1;
     update_main();
     update_running = 0;
-    empth_rwlock_unlock(play_lock);
+    empth_rwlock_unlock(update_lock);
 }
 
 int