Merge pull request #78 from cosmicpsyop/feature/freebsd-support-one

feature/freebsd-support-one: main freebsd adjustments
This commit is contained in:
Doug Hoyte
2023-12-16 11:00:52 -05:00
committed by GitHub
6 changed files with 25 additions and 3 deletions

View File

@ -17,6 +17,11 @@
#include "events.h"
#ifdef __FreeBSD__
extern char **environ;
#endif
enum class PluginEventSifterResult {
Accept,

View File

@ -143,7 +143,7 @@ class WSConnection : NonCopyable {
hubTrigger->setData(&asyncCb);
hubTrigger->start([](uS::Async *a){
auto *r = static_cast<std::function<void()> *>(a->data);
auto *r = static_cast<std::function<void()> *>(a->getData());
(*r)();
});

View File

@ -391,7 +391,7 @@ struct Router {
hubTrigger->setData(&asyncCb);
hubTrigger->start([](uS::Async *a){
auto *r = static_cast<std::function<void()> *>(a->data);
auto *r = static_cast<std::function<void()> *>(a->getData());
(*r)();
});

View File

@ -223,7 +223,7 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
hubTrigger->setData(&asyncCb);
hubTrigger->start([](uS::Async *a){
auto *r = static_cast<std::function<void()> *>(a->data);
auto *r = static_cast<std::function<void()> *>(a->getData());
(*r)();
});

View File

@ -1,4 +1,8 @@
#include <arpa/inet.h>
#ifdef __FreeBSD__
#include <sys/socket.h>
#include <netinet/in.h>
#endif
#include <stdio.h>
#include <signal.h>

View File

@ -58,9 +58,22 @@ static void setRLimits() {
if (getrlimit(RLIMIT_NOFILE, &curr)) throw herr("couldn't call getrlimit: ", strerror(errno));
#ifdef __FreeBSD__
LI << "getrlimit NOFILES limit current " << curr.rlim_cur << " with max of " << curr.rlim_max;
if (cfg().relay__nofiles > curr.rlim_max) {
LI << "Unable to set NOFILES limit to " << cfg().relay__nofiles << ", exceeds max of " << curr.rlim_max;
if (curr.rlim_cur < curr.rlim_max) {
LI << "Setting NOFILES limit to max of " << curr.rlim_max;
curr.rlim_cur = curr.rlim_max;
}
}
else curr.rlim_cur = cfg().relay__nofiles;
LI << "setrlimit NOFILES limit to " << curr.rlim_cur;
#else
if (cfg().relay__nofiles > curr.rlim_max) throw herr("Unable to set NOFILES limit to ", cfg().relay__nofiles, ", exceeds max of ", curr.rlim_max);
curr.rlim_cur = cfg().relay__nofiles;
#endif
if (setrlimit(RLIMIT_NOFILE, &curr)) throw herr("Failed setting NOFILES limit to ", cfg().relay__nofiles, ": ", strerror(errno));
}