is unsafe! By the time the blocked thread wakes up, that player may
be gone, along with its struct iop *, and io_write() follows a
dangling pointer. Moreover, at most one thread may use empth_select()
on the same file descriptor. Violations of that restriction cause
threads to hang under Windows since ntthread.c rev. 1.15. Make all
output to another player non-blocking for now. Historically, player
threads sent output only to their socket, though their own iop. This
was broken by flash and asynchronous telegram notification a long time
ago.
p = strchr(bp, '\n');
if (p != NULL) {
len = (p - bp) + 1;
- if (pl->command && (pl->command->c_flags & C_MOD))
+ if ((pl->command && (pl->command->c_flags & C_MOD)) ||
+ (player != pl))
io_write(pl->iop, bp, len, IO_NOWAIT);
else
io_write(pl->iop, bp, len, IO_WAIT);
}
}
if (ch == '\n') {
- if (pl->command && (pl->command->c_flags & C_MOD))
+ if ((pl->command && (pl->command->c_flags & C_MOD)) ||
+ (player != pl))
io_write(pl->iop, &ch, 1, IO_NOWAIT);
else
io_write(pl->iop, &ch, 1, IO_WAIT);