The journal logs a thread name for each event. The player thread name
changes on entry to the playing phase. Connecting old and new name
isn't as easy as it should be:
Sun Apr 29 12:13:39 2012 Conn29 input coun POGO
Sun Apr 29 12:13:39 2012 Conn29 input pass peter
Sun Apr 29 12:13:39 2012 Conn29 input play
Sun Apr 29 12:13:39 2012 Play#0 login 0 127.0.0.1 armbru
Sun Apr 29 12:15:39 2012 Play#0 logout 0
To connect Conn29 with Play#0, you have to know that country#0 is
named POGO.
Fix that by logging login before the thread name change:
Sun Apr 29 12:17:41 2012 Conn29 input coun POGO
Sun Apr 29 12:17:41 2012 Conn29 input pass peter
Sun Apr 29 12:17:41 2012 Conn29 input play
Sun Apr 29 12:17:41 2012 Conn29 login 0 127.0.0.1 armbru
Sun Apr 29 12:19:41 2012 Play#0 logout 0
Now "Conn29 login 0" makes the connection obvious.
This involves moving journal_login() from player_main() before
empth_set_name() in its caller play_cmd(). Move journal_logout() as
well, for symmetry.
If player_main() fails, we now log login/logout instead of nothing in
the journal. That's okay. Note that before commit
c9f21c0e (v4.3.8),
we logged just login then.
return RET_FAIL;
}
snprintf(buf, sizeof(buf), "Play#%d", player->cnum);
- empth_set_name(empth_self(), buf);
logerror("%s logged in as country #%d", praddr(player), player->cnum);
+ journal_login();
+ empth_set_name(empth_self(), buf);
pr_id(player, C_INIT, "%d\n", CLIENTPROTO);
empth_rwlock_rdlock(shutdown_lock);
player->state = PS_PLAYING;
player_main(player);
+ journal_logout();
logerror("%s logged out, country #%d", praddr(player), player->cnum);
if (!io_eof(player->iop) && !io_error(player->iop))
io_set_eof(player->iop);
#include "empio.h"
#include "empthread.h"
#include "file.h"
-#include "journal.h"
#include "misc.h"
#include "nat.h"
#include "optlist.h"
strcpy(natp->nat_hostaddr, player->hostaddr);
natp->nat_last_login = player->curup;
putnat(natp);
- journal_login();
if (natp->nat_flags & NF_INFORM && natp->nat_tgms > 0) {
if (natp->nat_tgms == 1)
pr("You have a new telegram waiting ...\n");
update_timeused(natp->nat_last_logout);
enforce_minimum_session_time();
pr("Bye-bye\n");
- journal_logout();
}
static int