crossroads

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

commit a9e440801e66c92ffbdf8cc7362fc0af36d32345
parent a597c987229349b08dad454f0bb599362e2602f7
Author: finwo <finwo@pm.me>
Date:   Sat,  3 Jan 2026 19:35:56 +0100

2.15

Diffstat:
MChangeLog | 10+++++++++-
MMakefile | 2+-
Mxr/balancer/balancer | 2++
Mxr/balancer/balancer1.cc | 3++-
Mxr/balancer/serve.cc | 3+++
Mxr/config/parsecmdline.cc | 9+++++++--
Mxr/etc/Makefile.class | 3++-
Mxr/sys/fdwrite.cc | 10++++++++--
8 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,6 +1,14 @@ +2.15 +- Sanity checks in Config::parsecmdline(): -w/-c together throws error. +- Network sends are now using write(), unless under Solaris, which + uses send(). +- --log-traffic logs to file with as the base name: the request + number. +- System (uname) is recorded during compilation and displayed in "xr -V" + 2.14 [KK 2008-09-30] - Removed spurious debug message. -- Fixed usage info for buffer size flag (should be -B). +- Fixed usage info for buffer size flag (should be -B, not -b). - Implemented flag -l (--log-traffic). 2.13 [KK 2008-09-17] diff --git a/Makefile b/Makefile @@ -1,7 +1,7 @@ # Top-level Makefile for XR # ------------------------- -VER = 2.14 +VER = 2.15 BINDIR = /usr/sbin TAR = /tmp/crossroads-$(VER).tar.gz AUTHOR = Karel Kubat <karel@kubat.nl> diff --git a/xr/balancer/balancer b/xr/balancer/balancer @@ -29,6 +29,7 @@ public: void terminate (bool t) { term = t; } bool report() const { return (rep); } void report (bool r) { rep = r; } + long requestnr() const { return (request_nr); } unsigned connections(); @@ -37,6 +38,7 @@ private: void init_fd (); int server_fd; + long request_nr; vector<Backend> backends; bool term; bool rep; diff --git a/xr/balancer/balancer1.cc b/xr/balancer/balancer1.cc @@ -1,4 +1,5 @@ #include "balancer" -Balancer::Balancer () : server_fd(-1), backends(), term(false), rep(false) { +Balancer::Balancer () : + server_fd(-1), request_nr(0), backends(), term(false), rep(false) { } diff --git a/xr/balancer/serve.cc b/xr/balancer/serve.cc @@ -81,6 +81,9 @@ void Balancer::serve() { continue; } } + + // Got activity! + request_nr++; if (server_fd) { // If tcp-serving: server_fd > 0; serve and loop again diff --git a/xr/config/parsecmdline.cc b/xr/config/parsecmdline.cc @@ -135,8 +135,8 @@ void Config::parsecmdline (int ac, char **av) { cout << "XR version : " << VER << "\n" << "Written by : " << AUTHOR << "\n" << "Maintained by : " << MAINTAINER << "\n" - << "Compiled with :\n" - << "C++ compiler : " << CONF_CC << "\n" + << "Compiled with : " << CONF_CC << "\n" + << "System : " << SYS << "\n" << "Libraries : " << CONF_LIB << "\n" ; # ifdef HAVE_GETOPT_H @@ -174,6 +174,7 @@ void Config::parsecmdline (int ac, char **av) { } } + // Sanity checks. if (ac != optind) throw static_cast<Error>("Bad command line '") + cmdline + "'\n" + USAGE; @@ -182,6 +183,10 @@ void Config::parsecmdline (int ac, char **av) { throw static_cast<Error> ("No backend defined, use '-b...' at least once, " "or try 'xr -h' for usage"); + if (checkup && wakeup) + throw static_cast<Error> + ("Use either --checkup-interval or --wakeup-interval, but not " + "both"); // In tryout mode, stop now. if (tryout) diff --git a/xr/etc/Makefile.class b/xr/etc/Makefile.class @@ -1,13 +1,14 @@ SRC = $(wildcard *.cc) OBJ = $(patsubst %.cc, $(BASE)/xr/$(BUILDDIR)/$(DIR)_%.o, $(SRC)) DIR = $(shell pwd | sed 's:.*/::') +SYS = $(shell uname) class-compile: $(OBJ) $(BASE)/xr/$(BUILDDIR)/$(DIR)_%.o: %.cc @echo "Compiling: " `pwd` $< @$(CONF_CC) -DVER='"$(VER)"' -DAUTHOR='"$(AUTHOR)"' \ - -DMAINTAINER='"$(MAINTAINER)"' \ + -DMAINTAINER='"$(MAINTAINER)"' -DSYS='"$(SYS)"' -D$(SYS) \ -DCONF_CC='"$(CONF_CC)"' -DCONF_LIB='"$(CONF_LIB)"' \ $(CONF_GETOPT) $(CONF_GETOPT_LONG) $(CONF_INET_ATON) \ -I$(BASE)/xr \ diff --git a/xr/sys/fdwrite.cc b/xr/sys/fdwrite.cc @@ -1,5 +1,6 @@ #include "sys" #include "fdset/fdset" +#include "balancer/balancer" void fdwrite (int fd, int timeout, char const *buf, unsigned buflen) { if (config.debug()) { @@ -12,7 +13,7 @@ void fdwrite (int fd, int timeout, char const *buf, unsigned buflen) { // Log to dump directory if requested if (config.dumpdir().length()) { ostringstream of; - of << config.dumpdir() << "/" << pthread_self() << "." << fd; + of << config.dumpdir() << "/" << balancer.requestnr() << "." << fd; FILE *f; if ( (!(f = fopen (of.str().c_str(), "a"))) && (!(f = fopen (of.str().c_str(), "w"))) ) @@ -36,14 +37,19 @@ void fdwrite (int fd, int timeout, char const *buf, unsigned buflen) { // Push bytes ssize_t nwritten; +# ifdef SunOS if (fd < 4) nwritten = write (fd, buf + totwritten, buflen - nwritten); else nwritten = send (fd, buf + totwritten, buflen - nwritten, 0); +# else + nwritten = write (fd, buf + totwritten, buflen - nwritten); +# endif if (config.debug()) { ostringstream o; - o << "Sent " << nwritten << " bytes to fd " << fd << "\n"; + o << "Sent " << static_cast<long>(nwritten) + << " bytes to fd " << fd << "\n"; debugmsg (o.str()); }