DC-11: locking fix

This commit is contained in:
folkert van heusden 2024-05-04 16:17:56 +02:00
parent e12507eb7c
commit 44317e69c0
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1

View file

@ -119,6 +119,8 @@ void dc11::operator()()
pfds[client_i].fd = accept(pfds[i].fd, nullptr, nullptr); pfds[client_i].fd = accept(pfds[i].fd, nullptr, nullptr);
set_nodelay(pfds[client_i].fd); set_nodelay(pfds[client_i].fd);
std::unique_lock<std::mutex> lck(input_lock[i]);
registers[i * 4 + 0] |= 0160000; // "ERROR", RING INDICATOR, CARRIER TRANSITION registers[i * 4 + 0] |= 0160000; // "ERROR", RING INDICATOR, CARRIER TRANSITION
if (is_rx_interrupt_enabled(i)) if (is_rx_interrupt_enabled(i))
trigger_interrupt(i); trigger_interrupt(i);
@ -129,11 +131,11 @@ void dc11::operator()()
if (pfds[i].revents != POLLIN) if (pfds[i].revents != POLLIN)
continue; continue;
int line_nr = i - dc11_n_lines;
char buffer[32] { }; char buffer[32] { };
int rc = read(pfds[i].fd, buffer, sizeof buffer); int rc = read(pfds[i].fd, buffer, sizeof buffer);
int line_nr = i - dc11_n_lines;
std::unique_lock<std::mutex> lck(input_lock[line_nr]); std::unique_lock<std::mutex> lck(input_lock[line_nr]);
if (rc <= 0) { // closed or error? if (rc <= 0) { // closed or error?