InterLinked1 / lbbs

Lightweight BBS For Linux - Bulletin Board System server software

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logger.c: Logging can get stuck on remote consoles

InterLinked1 opened this issue · comments

Split off from #12, since this is a separate issue:

Logging can also get stuck here due to write blocking forever:

RWLIST_RDLOCK(&remote_log_fds);
RWLIST_TRAVERSE(&remote_log_fds, rfd, entry) {
	if (fd_logging[rfd->fd]) {
		write(rfd->fd, fullbuf, (size_t) bytes);
	}
}
RWLIST_UNLOCK(&remote_log_fds);

A somewhat easy way to reproduce this (a scenario where this happens frequently) is if the consoles are being spammed with log messages and you exit a remote sysop console using ^C. Perhaps the console file descriptors are going away while they are being logged to, but that doesn't entirely make sense either.

This causes a deadlock, but only at the thread level, i.e. not all logging is broken. Because threads get stuck with a RDLOCK held on the remote logger fd's, it becomes impossible to obtain a WRLOCK, which blocks sysop console registration/unregistration. Otherwise, other logging and other threads remain nominally unaffected.