InterLinked1 / lbbs

Lightweight BBS For Linux - Bulletin Board System server software
GNU General Public License v2.0
35 stars 4 forks source link

logger.c: Logging can get stuck on remote consoles #13

Closed InterLinked1 closed 1 year ago

InterLinked1 commented 1 year ago

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.