From 16bcd3cdf36735e4fdaf1add69e6f0e4e87fbded Mon Sep 17 00:00:00 2001 From: SimulPiscator Date: Sat, 4 Nov 2023 18:31:28 +0100 Subject: [PATCH] Trying to address #110 --- README.md | 2 -- web/httpserver.cpp | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e18c05c..f634582 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,6 @@ as XSane or simple-scan should be able to scan from them. eSCL support in Windows has been introduced in Windows 11 first, but is now available in Windows 10 as well: -Unfortunately, eSCL scanning from Windows seems to be broken as of Nov. 2023. - #### Connecting to an AirSane scanner Go to "Settings"->"Bluetooth & devices"->"Printers and Scanners." There, click "Add Device". diff --git a/web/httpserver.cpp b/web/httpserver.cpp index 1628b1f..e86c143 100644 --- a/web/httpserver.cpp +++ b/web/httpserver.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #include #include #include +#include #include #ifdef __FreeBSD__ @@ -200,6 +201,7 @@ struct HttpServer::Private std::string mInterfaceName, mUnixSocket; int mInterfaceIndex, mBacklog; AccessFile mAccessFile; + std::mutex mAccessFileMutex; std::atomic mRunning; std::atomic mPipeWriteFd; @@ -374,10 +376,12 @@ struct HttpServer::Private void handleRequest(int fd, Sockaddr address) { + std::unique_lock lock(mAccessFileMutex); if (!mAccessFile.isAllowed(address)) { ::close(fd); return; } + lock.unlock(); fdbuf buf(fd); std::istream is(&buf); @@ -562,6 +566,7 @@ HttpServer::backlog() const HttpServer& HttpServer::applyAccessFile(const AccessFile& file) { + std::lock_guard lock(p->mAccessFileMutex); p->mAccessFile = file; return *this; }