Skip to content

Commit

Permalink
Trying to address #110
Browse files Browse the repository at this point in the history
  • Loading branch information
SimulPiscator committed Nov 4, 2023
1 parent a908079 commit 16bcd3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://support.microsoft.com/en-us/topic/june-28-2022-kb5014666-os-builds-19042-1806-19043-1806-and-19044-1806-preview-4bd911df-f290-4753-bdec-a83bc8709eb6>

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".
Expand Down
5 changes: 5 additions & 0 deletions web/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <ctime>
#include <sstream>
#include <thread>
#include <mutex>

#include <arpa/inet.h>
#ifdef __FreeBSD__
Expand Down Expand Up @@ -200,6 +201,7 @@ struct HttpServer::Private
std::string mInterfaceName, mUnixSocket;
int mInterfaceIndex, mBacklog;
AccessFile mAccessFile;
std::mutex mAccessFileMutex;

std::atomic<bool> mRunning;
std::atomic<int> mPipeWriteFd;
Expand Down Expand Up @@ -374,10 +376,12 @@ struct HttpServer::Private

void handleRequest(int fd, Sockaddr address)
{
std::unique_lock<std::mutex> lock(mAccessFileMutex);
if (!mAccessFile.isAllowed(address)) {
::close(fd);
return;
}
lock.unlock();

fdbuf buf(fd);
std::istream is(&buf);
Expand Down Expand Up @@ -562,6 +566,7 @@ HttpServer::backlog() const
HttpServer&
HttpServer::applyAccessFile(const AccessFile& file)
{
std::lock_guard<std::mutex> lock(p->mAccessFileMutex);
p->mAccessFile = file;
return *this;
}
Expand Down

0 comments on commit 16bcd3c

Please sign in to comment.