Skip to content

Commit

Permalink
Merge pull request #78 from cosmicpsyop/feature/freebsd-support-one
Browse files Browse the repository at this point in the history
feature/freebsd-support-one: main freebsd adjustments
  • Loading branch information
hoytech authored Dec 16, 2023
2 parents b63eada + f0a4a90 commit 80f41ba
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/PluginEventSifter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

#include "events.h"

#ifdef __FreeBSD__
extern char **environ;
#endif



enum class PluginEventSifterResult {
Accept,
Expand Down
2 changes: 1 addition & 1 deletion src/WSConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
});

Expand Down
2 changes: 1 addition & 1 deletion src/apps/mesh/cmd_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
});

Expand Down
2 changes: 1 addition & 1 deletion src/apps/relay/RelayWebsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
});

Expand Down
4 changes: 4 additions & 0 deletions src/misc.cpp
Original file line number Diff line number Diff line change
@@ -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>

Expand Down
13 changes: 13 additions & 0 deletions src/onAppStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 80f41ba

Please sign in to comment.