From 44317e69c034c236da3ca58c0bd0b5f0a9535514 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 4 May 2024 16:17:56 +0200 Subject: [PATCH] DC-11: locking fix --- dc11.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dc11.cpp b/dc11.cpp index aff442b..d6c1843 100644 --- a/dc11.cpp +++ b/dc11.cpp @@ -119,6 +119,8 @@ void dc11::operator()() pfds[client_i].fd = accept(pfds[i].fd, nullptr, nullptr); set_nodelay(pfds[client_i].fd); + std::unique_lock lck(input_lock[i]); + registers[i * 4 + 0] |= 0160000; // "ERROR", RING INDICATOR, CARRIER TRANSITION if (is_rx_interrupt_enabled(i)) trigger_interrupt(i); @@ -129,11 +131,11 @@ void dc11::operator()() if (pfds[i].revents != POLLIN) continue; - int line_nr = i - dc11_n_lines; - char buffer[32] { }; int rc = read(pfds[i].fd, buffer, sizeof buffer); + int line_nr = i - dc11_n_lines; + std::unique_lock lck(input_lock[line_nr]); if (rc <= 0) { // closed or error?