diff --git a/gui/main.cpp b/gui/main.cpp index df19160..dc22d32 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -35,20 +35,20 @@ void enableSandbox(QString socketPath) EXILE_SYSCALL_VOW_PROT_EXEC | EXILE_SYSCALL_VOW_PROC | EXILE_SYSCALL_VOW_SHM | EXILE_SYSCALL_VOW_FSNOTIFY | EXILE_SYSCALL_VOW_IOCTL; - if(exile_append_path_policy(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_REMOVE_FILE, "/") != 0) + if(exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_REMOVE_FILE, "/") != 0) { qCritical() << "Failed to append a path to the path policy"; exit(EXIT_FAILURE); } - if(exile_append_path_policy(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE, appDataLocation.c_str()) != - 0) + if(exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE, + appDataLocation.c_str()) != 0) { qCritical() << "Failed to append a path to the path policy"; exit(EXIT_FAILURE); } - if(exile_append_path_policy(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE, - cacheDataLocation.c_str()) != 0) + if(exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE, + cacheDataLocation.c_str()) != 0) { qCritical() << "Failed to append a path to the path policy"; exit(EXIT_FAILURE); diff --git a/shared/concurrentqueue.cpp b/shared/concurrentqueue.cpp new file mode 100644 index 0000000..3e1a90f --- /dev/null +++ b/shared/concurrentqueue.cpp @@ -0,0 +1 @@ +#include "concurrentqueue.h" diff --git a/shared/concurrentqueue.h b/shared/concurrentqueue.h new file mode 100644 index 0000000..821eb1a --- /dev/null +++ b/shared/concurrentqueue.h @@ -0,0 +1,67 @@ +#ifndef CONCURRENTQUEUE_H +#define CONCURRENTQUEUE_H +#include +#include +#include + +#define QUEUE_SIZE 10000 +template class ConcurrentQueue : protected QList +{ + protected: + QMutex mutex; + + QSemaphore avail{QUEUE_SIZE}; + + public: + void enqueue(const T &t) + { + avail.acquire(1); + QMutexLocker locker(&mutex); + QList::append(t); + } + + QVector dequeue(int batchsize) + { + avail.release(batchsize); + // TODO: this sucks + QVector result; + QMutexLocker locker(&mutex); + for(int i = 0; i < batchsize; i++) + { + result.append(QList::takeFirst()); + } + return result; + } + + void enqueue(const QVector &t) + { + QList tmp(t.begin(), t.end()); + avail.acquire(t.size()); + QMutexLocker locker(&mutex); + QList::append(tmp); + } + + unsigned int remaining() + { + return QUEUE_SIZE - avail.available(); + } + + void clear() + { + QMutexLocker locker(&mutex); + QList::clear(); + avail.release(QUEUE_SIZE); + } + + bool dequeue(T &result) + { + QMutexLocker locker(&mutex); + if(QList::isEmpty()) + return false; + avail.release(1); + result = QList::takeFirst(); + return true; + } +}; + +#endif // CONCURRENTQUEUE_H diff --git a/shared/sandboxedprocessor.cpp b/shared/sandboxedprocessor.cpp index 69444ba..1b4ede5 100644 --- a/shared/sandboxedprocessor.cpp +++ b/shared/sandboxedprocessor.cpp @@ -37,7 +37,7 @@ void SandboxedProcessor::enableSandbox(QString readablePath) if(!readablePath.isEmpty()) { std::string readablePathLocation = readablePath.toStdString(); - if(exile_append_path_policy(policy, EXILE_FS_ALLOW_ALL_READ, readablePathLocation.c_str()) != 0) + if(exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ, readablePathLocation.c_str()) != 0) { qCritical() << "Failed to add path policies"; exit(EXIT_FAILURE); @@ -102,7 +102,7 @@ int SandboxedProcessor::process() } catch(LooqsGeneralException &e) { - Logger::error() << "Error while processing" << absPath << ":" << e.message << Qt::endl; + Logger::error() << "SandboxedProcessor: Error while processing" << absPath << ":" << e.message << Qt::endl; return 3 /* PROCESSFAIL */; } diff --git a/submodules/exile.h b/submodules/exile.h index 4824c6e..ea66ef7 160000 --- a/submodules/exile.h +++ b/submodules/exile.h @@ -1 +1 @@ -Subproject commit 4824c6eaa9043878daaba7b3778338f5bf913f06 +Subproject commit ea66ef76ebb88a43ac25c9a86f8fcab8efa130b2