From b22e515a71651718e86687f29cf28cdb5d525db1 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Tue, 24 Oct 2023 03:31:54 -0700 Subject: [PATCH 1/7] feature/freebsd-support-one: main freebsd adjustments --- src/PluginEventSifter.h | 5 +++++ src/WSConnection.h | 2 +- src/apps/mesh/cmd_router.cpp | 2 +- src/apps/relay/RelayWebsocket.cpp | 2 +- src/misc.cpp | 4 ++++ src/onAppStartup.cpp | 5 +++++ 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/PluginEventSifter.h b/src/PluginEventSifter.h index c923245..f04e445 100644 --- a/src/PluginEventSifter.h +++ b/src/PluginEventSifter.h @@ -17,6 +17,11 @@ #include "events.h" +#ifdef __FreeBSD__ +extern char **environ; +#endif + + enum class PluginEventSifterResult { Accept, diff --git a/src/WSConnection.h b/src/WSConnection.h index c9e109f..2da7f3a 100644 --- a/src/WSConnection.h +++ b/src/WSConnection.h @@ -143,7 +143,7 @@ class WSConnection : NonCopyable { hubTrigger->setData(&asyncCb); hubTrigger->start([](uS::Async *a){ - auto *r = static_cast *>(a->data); + auto *r = static_cast *>(a->getData()); (*r)(); }); diff --git a/src/apps/mesh/cmd_router.cpp b/src/apps/mesh/cmd_router.cpp index 45203f3..248b3ef 100644 --- a/src/apps/mesh/cmd_router.cpp +++ b/src/apps/mesh/cmd_router.cpp @@ -391,7 +391,7 @@ struct Router { hubTrigger->setData(&asyncCb); hubTrigger->start([](uS::Async *a){ - auto *r = static_cast *>(a->data); + auto *r = static_cast *>(a->getData()); (*r)(); }); diff --git a/src/apps/relay/RelayWebsocket.cpp b/src/apps/relay/RelayWebsocket.cpp index cf4d16b..23bec51 100644 --- a/src/apps/relay/RelayWebsocket.cpp +++ b/src/apps/relay/RelayWebsocket.cpp @@ -223,7 +223,7 @@ void RelayServer::runWebsocket(ThreadPool::Thread &thr) { hubTrigger->setData(&asyncCb); hubTrigger->start([](uS::Async *a){ - auto *r = static_cast *>(a->data); + auto *r = static_cast *>(a->getData()); (*r)(); }); diff --git a/src/misc.cpp b/src/misc.cpp index 8ce9f23..04829ce 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -1,4 +1,8 @@ #include +#ifdef __FreeBSD__ +#include +#include +#endif #include #include diff --git a/src/onAppStartup.cpp b/src/onAppStartup.cpp index 55fcef4..65214f8 100644 --- a/src/onAppStartup.cpp +++ b/src/onAppStartup.cpp @@ -69,5 +69,10 @@ static void setRLimits() { void onAppStartup(lmdb::txn &txn, const std::string &cmd) { dbCheck(txn, cmd); +#ifndef __FreeBSD__ + // XXX - strfry error: Unable to set NOFILES limit to 1000000, exceeds max of 116991 + // XXX - warning: comparison of integer expressions of different signedness: + // XXX 'const uint64_t' {aka 'const long unsigned int'} and 'rlim_t' {aka 'long int'} [-Wsign-compare] setRLimits(); +#endif } From 4736f37da69609c322f22da772746614622cc634 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Tue, 24 Oct 2023 03:52:00 -0700 Subject: [PATCH 2/7] Update gople module --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index e59bb8c..bdec3a3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "golpe"] path = golpe - url = https://github.com/hoytech/golpe.git + url = https://github.com/cosmicpsyop/golpe.git [submodule "external/negentropy"] path = external/negentropy url = https://github.com/hoytech/negentropy.git From bc21e7b16c7f1abd24c9b14d725bc7f36e690c91 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Wed, 25 Oct 2023 01:42:14 -0700 Subject: [PATCH 3/7] setRLimits refactor to snarf as many handles available up to asked for --- src/onAppStartup.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/onAppStartup.cpp b/src/onAppStartup.cpp index 65214f8..aecaa6c 100644 --- a/src/onAppStartup.cpp +++ b/src/onAppStartup.cpp @@ -58,9 +58,21 @@ 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)); } @@ -69,10 +81,5 @@ static void setRLimits() { void onAppStartup(lmdb::txn &txn, const std::string &cmd) { dbCheck(txn, cmd); -#ifndef __FreeBSD__ - // XXX - strfry error: Unable to set NOFILES limit to 1000000, exceeds max of 116991 - // XXX - warning: comparison of integer expressions of different signedness: - // XXX 'const uint64_t' {aka 'const long unsigned int'} and 'rlim_t' {aka 'long int'} [-Wsign-compare] setRLimits(); -#endif } From f0ee6a91b8eecc2bbb127ca361b7634512a1f78c Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Tue, 7 Nov 2023 09:32:19 -0800 Subject: [PATCH 4/7] feature/freebsd-support-one: restore line --- src/onAppStartup.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/onAppStartup.cpp b/src/onAppStartup.cpp index aecaa6c..17aeda4 100644 --- a/src/onAppStartup.cpp +++ b/src/onAppStartup.cpp @@ -71,6 +71,7 @@ static void setRLimits() { 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 From ae24826a37b268b67d33110c7b56905bb872c396 Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Tue, 7 Nov 2023 10:32:39 -0800 Subject: [PATCH 5/7] feature/freebsd-support-one: revert modules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index bdec3a3..e59bb8c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "golpe"] path = golpe - url = https://github.com/cosmicpsyop/golpe.git + url = https://github.com/hoytech/golpe.git [submodule "external/negentropy"] path = external/negentropy url = https://github.com/hoytech/negentropy.git From 62ed4b901dcf393bd982db0078c0941f8841b56b Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Tue, 7 Nov 2023 21:10:28 -0800 Subject: [PATCH 6/7] feature/freebsd-support-one: revert revert modules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index e59bb8c..bdec3a3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "golpe"] path = golpe - url = https://github.com/hoytech/golpe.git + url = https://github.com/cosmicpsyop/golpe.git [submodule "external/negentropy"] path = external/negentropy url = https://github.com/hoytech/negentropy.git From f0a4a9054d1a06d0d7975921d12ae11673d1de3d Mon Sep 17 00:00:00 2001 From: cosmicpsyop Date: Wed, 8 Nov 2023 19:11:06 -0800 Subject: [PATCH 7/7] feature/freebsd-support-one: revert revert revert --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index bdec3a3..e59bb8c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "golpe"] path = golpe - url = https://github.com/cosmicpsyop/golpe.git + url = https://github.com/hoytech/golpe.git [submodule "external/negentropy"] path = external/negentropy url = https://github.com/hoytech/negentropy.git