(exit_nomem): New.

(update_init): New.
(start_server): Call it.
(start_server, update_sched): Move initialization stuff to it, with
error checking added.
(update_sched): Internal linkage.
This commit is contained in:
Markus Armbruster 2007-01-16 19:26:31 +00:00
parent 6cbdd3e02a
commit d38fcc6cf4
5 changed files with 40 additions and 11 deletions

View file

@ -51,20 +51,34 @@ empth_sem_t *update_sem;
empth_rwlock_t *update_lock;
time_t update_time;
static void update_sched(void *);
static void update_wait(void *unused);
static int run_hook(char *cmd, char *name);
/*ARGSUSED*/
void
update_init(void)
{
update_sem = empth_sem_create("Update", 0);
update_lock = empth_rwlock_create("Update");
if (!update_sem || !update_lock)
exit_nomem();
if (!empth_create(PP_SCHED, update_wait, 50 * 1024, 0,
"Update", "Updates the world", NULL))
exit_nomem();
if (!empth_create(PP_SCHED, update_sched, 50 * 1024, 0,
"UpdateSched", "Schedules updates to occur", NULL))
exit_nomem();
}
/*ARGSUSED*/
static void
update_sched(void *unused)
{
int wind;
time_t now, delta;
update_sem = empth_sem_create("Update", 0);
update_lock = empth_rwlock_create("Update");
empth_create(PP_SCHED, update_wait, (50 * 1024), 0, "UpdateWait",
"Waits until players idle", 0);
if (s_p_etu <= 0) {
logerror("bad value for s_p_etu (%d)", s_p_etu);
s_p_etu = 2 * 60;