crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

commit 6b9f07bd784121793ff9c63689152d51c8c1b823
parent 3ac969a7894acbfae13297c02a36e8e93603a59d
Author: finwo <finwo@pm.me>
Date:   Sat,  3 Jan 2026 19:36:32 +0100

2.35

Diffstat:
MChangeLog | 8++++++++
MMakefile | 2+-
Mdoc/xr.odt | 0
Mdoc/xr.pdf | 0
Mdoc/xrctl.xml.5 | 16++++++++--------
Mxr/Checkers/checkupthread/execute.cc | 33++++++++++++++++++---------------
Mxr/Checkers/wakeupthread/execute.cc | 23+++++++++++++----------
Mxr/balancer/serve.cc | 10++++++----
Mxr/config/config | 1+
Mxr/etc/status.xslt | 24++++++++++++++++++++----
Mxr/webinterface/answer.cc | 7+++++++
11 files changed, 82 insertions(+), 42 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,11 @@ +2.35 [KK 2008-11-11] +- The wakeup and checkup thread are always started, even when no + wakeups or checkups are defined. Reason is that later these timers + can be set in the web interface, so we want the threads running. + When no checks/wakeups are applicable, the threads will recheck each + 30 secs. +- Server type (tcp/http) made configurable through the web interface. + 2.34 [KK 2008-11-09] - Fixed sys/str2parts.cc for 64bit systems. diff --git a/Makefile b/Makefile @@ -1,7 +1,7 @@ # Top-level Makefile for XR # ------------------------- -VER = 2.34 +VER = 2.35 PREFIX = $(DESTDIR)/usr BINDIR = $(PREFIX)/sbin MANDIR = $(PREFIX)/share/man diff --git a/doc/xr.odt b/doc/xr.odt Binary files differ. diff --git a/doc/xr.pdf b/doc/xr.pdf Binary files differ. diff --git a/doc/xrctl.xml.5 b/doc/xrctl.xml.5 @@ -131,7 +131,7 @@ distributed with the sources for a full description. softmaxconnrate (here: 150), then each connection is delayed for defertime microsecs (here: 1.000.000, one sec). - Finally, the entire balancer will be allowed to serve up + Finally, the entire balancer will be allowed to serve up to 400 simultaneous connections. --> <timeinterval>2</timeinterval> @@ -140,13 +140,13 @@ distributed with the sources for a full description. <defertime>1000000</defertime> <maxconnections>400</maxconnections> - <!-- Let's add some more protection. When a user exceeds their - hard maxconn rate, "/path/to/program" will be invoked - with the IP as argument. That program may eg. call - iptables to block the client. There is also a tag - softmaxconnexcess (not shown here). --> - <hardmaxconnexcess>/path/to/program</hardmaxconnexcess> - + <!-- Let's add some more protection. When a user exceeds their + hard maxconn rate, "/path/to/program" will be invoked + with the IP as argument. That program may eg. call + iptables to block the client. There is also a tag + softmaxconnexcess (not shown here). --> + <hardmaxconnexcess>/path/to/program</hardmaxconnexcess> + </dosprotection> <http> diff --git a/xr/Checkers/checkupthread/execute.cc b/xr/Checkers/checkupthread/execute.cc @@ -2,22 +2,25 @@ void Checkupthread::execute() { while (1) { - for (unsigned i = 0; i < balancer.nbackends(); i++) { - Backend target(balancer.backend(i).backenddef()); - target.check(); - if (! balancer.backend(i).live() && - target.live() ) { - balancer.backend(i).live(true); - msg ("Checkup call: backend " + target.description() + - " has awoken\n"); - } else if (balancer.backend(i).live() && - ! target.live()) { - balancer.backend(i).live(false); - msg ("Checkup call: backend " + target.description() + - " has gone asleep\n"); + if (config.checkupsec()) { + for (unsigned i = 0; i < balancer.nbackends(); i++) { + Backend target(balancer.backend(i).backenddef()); + target.check(); + if (! balancer.backend(i).live() && + target.live() ) { + balancer.backend(i).live(true); + msg ("Checkup call: backend " + target.description() + + " has awoken\n"); + } else if (balancer.backend(i).live() && + ! target.live()) { + balancer.backend(i).live(false); + msg ("Checkup call: backend " + target.description() + + " has gone asleep\n"); + } } - } - sleep (config.checkupsec()); + sleep (config.checkupsec()); + } else + sleep(30); } } diff --git a/xr/Checkers/wakeupthread/execute.cc b/xr/Checkers/wakeupthread/execute.cc @@ -2,18 +2,21 @@ void Wakeupthread::execute() { while (1) { - for (unsigned i = 0; i < balancer.nbackends(); i++) { - if (! balancer.backend(i).live()) { - Backend target(balancer.backend(i).backenddef()); - target.check(); - if (target.live()) { - msg ("Wakeup call: backend " + target.description() + - " has awoken\n"); - balancer.backend(i).live(true); + if (config.wakeupsec()) { + for (unsigned i = 0; i < balancer.nbackends(); i++) { + if (! balancer.backend(i).live()) { + Backend target(balancer.backend(i).backenddef()); + target.check(); + if (target.live()) { + msg ("Wakeup call: backend " + target.description() + + " has awoken\n"); + balancer.backend(i).live(true); + } } } - } - sleep (config.wakeupsec()); + sleep (config.wakeupsec()); + } else + sleep(30); } } diff --git a/xr/balancer/serve.cc b/xr/balancer/serve.cc @@ -5,15 +5,17 @@ void Balancer::serve() { int clsock; - // Start up wakeup/checkup handlers. - if (config.wakeupsec() && !config.foregroundmode() && config.sport()) { + // Start up wakeup/checkup handlers. These are always started - even + // when config.wakeupsec() and config.checkupsec() are not defined + // and have value 0. Via the web interface, the values can be later + // changed, but we want to have the checkers running always. + if (!config.foregroundmode() && config.sport()) { msg ("Starting wakeup thread.\n"); Wakeupthread *wt = new Wakeupthread(); if (!wt) throw static_cast<Error>("Memory fault in Balancer::serve"); wt->start(); - } - if (config.checkupsec() && !config.foregroundmode() && config.sport()) { + msg ("Starting checkup thread.\n"); Checkupthread *ct = new Checkupthread(); if (!ct) diff --git a/xr/config/config b/xr/config/config @@ -28,6 +28,7 @@ public: unsigned quitafter() const { return (quit_after); } Servertype::Type stype() const { return (styp.type()); } + void stype(string const &s) { styp.type(s); } string stypestr() const { return (styp.typestr()); } string sipaddr() const { return (sip); } int sport() const { return (lport); } diff --git a/xr/etc/status.xslt b/xr/etc/status.xslt @@ -115,14 +115,30 @@ </td> </tr> <tr> - <td>Type</td> - <td colspan="3"> <xsl:value-of select="type"/> </td> - </tr> - <tr> <td>Dispatch mode</td> <td colspan="3"> <xsl:value-of select="dispatchmode"/> </td> </tr> <tr> + <td>Type</td> + <td colspan="2"></td> + <td> + <xsl:choose> + <xsl:when test="type = 'http'"> + <select onchange="goto('/server/type/tcp', '');"> + <option value="tcp">tcp</option> + <option value="http" selected="1">http</option> + </select> + </xsl:when> + <xsl:otherwise> + <select onchange="goto('/server/type/http', '');"> + <option value="tcp" selected="1">tcp</option> + <option value="http">http</option> + </select> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> + <tr> <td>Checks</td> <td>Wakeup interval</td> <td> diff --git a/xr/webinterface/answer.cc b/xr/webinterface/answer.cc @@ -386,6 +386,13 @@ void Webinterface::answer(Httpbuffer req) { return; } + // /server/type/http, /server/type/tcp + if (parts.size() == 3 && parts[0] == "server" && parts[1] == "type") { + config.stype(parts[2]); + answer_status(); + return; + } + // /backend/NR/weight/NUMBER if (parts.size() == 4 && parts[0] == "backend" && parts[2] == "weight") {