crossroads

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

commit 9e312385bdad58077b1ac94ff2324dbc0bb6c296
parent 9a29143ff9b71e0aac3912debb8deae4ad4414cd
Author: finwo <finwo@pm.me>
Date:   Sat,  3 Jan 2026 19:38:29 +0100

2.64

Diffstat:
MChangeLog | 5+++++
MMakefile | 2+-
Mdoc/xr.odt | 0
Mdoc/xr.pdf | 0
Mxr/balancer/balancer | 1+
Mxr/balancer/balancer1.cc | 2+-
Mxr/balancer/init.cc | 6+++---
Mxr/balancer/serve.cc | 1+
Mxr/sys/main.cc | 10+---------
Mxr/webinterface/answer.cc | 1+
Mxr/webinterface/answerstatus.cc | 1+
Mxr/webinterface/execute.cc | 7+++++--
Mxr/webinterface/webinterface | 6++++--
Axr/webinterface/webinterface1.cc | 8++++++++
14 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +2.64 [KK 2010-01-29] +- Fixed signal handling for start/stop/restart. +- Web interface now immediately shuts down at a stop request, so that + next xr instances can grab the web interface port immediately. + 2.63 [KK 2010-01-11] - Previous 2.62 stamped as stable, 2.63 will be the new development trunk. diff --git a/Makefile b/Makefile @@ -1,7 +1,7 @@ # Top-level Makefile for XR # ------------------------- -VER = 2.63 +VER = 2.64 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/xr/balancer/balancer b/xr/balancer/balancer @@ -50,6 +50,7 @@ private: bool term; bool rep; bool rest; + Webinterface *webinterface; }; extern Balancer balancer; diff --git a/xr/balancer/balancer1.cc b/xr/balancer/balancer1.cc @@ -2,5 +2,5 @@ Balancer::Balancer () : server_fd(-1), request_nr(0), backends(), - term(false), rep(false), rest(false) { + term(false), rep(false), rest(false), webinterface(0) { } diff --git a/xr/balancer/init.cc b/xr/balancer/init.cc @@ -15,10 +15,10 @@ void Balancer::init() { // Start the web interface if requested. if (config.usewebinterface() && !config.foregroundmode()) { - Webinterface *w = new Webinterface(); - if (! w) + webinterface = new Webinterface(); + if (! webinterface) throw Error("Memory fault in Balancer::init"); - w->start(); + webinterface->start(); } // Add workable back ends, display initial states. diff --git a/xr/balancer/serve.cc b/xr/balancer/serve.cc @@ -198,6 +198,7 @@ void Balancer::serve() { // Wait for running threads to die off. socketclose (server_fd); + delete webinterface; unsigned prev_conn = 0x19081962; while (1) { unsigned curr_conn = balancer.connections(); diff --git a/xr/sys/main.cc b/xr/sys/main.cc @@ -56,16 +56,9 @@ static void sigcatcher (int sig) { * web interface. */ balancer.report(true); break; - case SIGPIPE: - case SIGSTOP: - /* SIGPIPE is ignored (See below). Leaving in place for future - * versions. SIGSTOP is used for stopping separarte treads. */ + default: balancer.terminate(true); break; - case SIGSEGV: - /* Production-grade protection - don't ever crash! */ - balancer.restart(true); - break; } } @@ -75,7 +68,6 @@ int main (int argc, char **argv) { static int relevant_sig[] = { SIGHUP, SIGINT, SIGQUIT, SIGABRT, SIGTERM, SIGSTOP, - // SIGSEGV }; try { diff --git a/xr/webinterface/answer.cc b/xr/webinterface/answer.cc @@ -1,4 +1,5 @@ #include "webinterface" +#include "balancer/balancer" static void stop_backend_thread(pthread_t id) { Threadinfo info = Threadlist::info(id); diff --git a/xr/webinterface/answerstatus.cc b/xr/webinterface/answerstatus.cc @@ -1,4 +1,5 @@ #include "webinterface" +#include "balancer/balancer" void Webinterface::answer_status() { string xml = diff --git a/xr/webinterface/execute.cc b/xr/webinterface/execute.cc @@ -1,11 +1,14 @@ #include "webinterface" +#include "balancer/balancer" void Webinterface::execute() { - int sfd; - Threadlist::desc("Web interface"); // Create the server socket, or retry infinitely. + // This is maybe a too big precaution - previous xr's are responsible + // for killing off their web interfaces. But we don't want a new xr + // start to croak and cause downtime just because the web interface, + // so we just retry for a bit. while (true) { try { msg ("Starting web interface\n"); diff --git a/xr/webinterface/webinterface b/xr/webinterface/webinterface @@ -6,11 +6,13 @@ #include "ThreadsAndMutexes/threadlist/threadlist" #include "fdset/fdset" #include "httpbuffer/httpbuffer" -#include "balancer/balancer" class Webinterface: public Thread { public: + Webinterface() { cfd = 0; sfd = 0; } + virtual ~Webinterface(); void execute(); + private: void serve(); void answer(Httpbuffer r); @@ -19,7 +21,7 @@ private: void answer_blob (string const &b); - int cfd; + int cfd, sfd; }; #endif diff --git a/xr/webinterface/webinterface1.cc b/xr/webinterface/webinterface1.cc @@ -0,0 +1,8 @@ +#include "webinterface" + +Webinterface::~Webinterface() { + if (cfd) { + msg ((Mstr("Stopping web interface socket ") + sfd) + "\n"); + socketclose(sfd); + } +}