crossroads

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

commit ac9f1215fb01739f7fac2ac584135cf7b74a818b
parent 42b59853f31cfc5a45104fc891507377a0a85de2
Author: finwo <finwo@pm.me>
Date:   Sat,  3 Jan 2026 19:36:01 +0100

2.17

Diffstat:
MChangeLog | 4++++
MMakefile | 2+-
Mxr/backend/backend | 2+-
Mxr/config/parsecmdline.cc | 5+++++
Mxr/sys/fdwrite.cc | 11+++++------
Mxr/tcpdispatcher/handle.cc | 30++++++++++++++++++++----------
6 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +2.17 +- Type sizes reported in "xr -V" +- Fixed nasty bug in sys/fdwrite.cc + 2.16 - Enhanced web interface to show debug, verbose and traffic log states - Altering parameters for the web interface get sent in encoded form diff --git a/Makefile b/Makefile @@ -1,7 +1,7 @@ # Top-level Makefile for XR # ------------------------- -VER = 2.16 +VER = 2.17 BINDIR = /usr/sbin TAR = /tmp/crossroads-$(VER).tar.gz AUTHOR = Karel Kubat <karel@kubat.nl> diff --git a/xr/backend/backend b/xr/backend/backend @@ -35,7 +35,7 @@ public: void weight (unsigned w) { bdef.weight(w); } unsigned adjustedweight() const { return (bdef.adjustedweight()); } unsigned connections() const { return (nconn); } - double bytesserved() const { return (bytes_served); } + double bytesserved() const { return (bytes_served); } unsigned clientsserved() const { return (totconn); } void addbytes (unsigned n); diff --git a/xr/config/parsecmdline.cc b/xr/config/parsecmdline.cc @@ -138,6 +138,11 @@ void Config::parsecmdline (int ac, char **av) { << "Compiled with : " << CONF_CC << "\n" << "System : " << SYS << "\n" << "Libraries : " << CONF_LIB << "\n" + << "Type sizes : ssize_t=" << sizeof(ssize_t) + << ", int=" << sizeof(int) + << ", long=" << sizeof(long) + << ", double=" << sizeof(double) + << ", ptr=" << sizeof(char*) << "\n" ; # ifdef HAVE_GETOPT_H cout << "getopt.h : present\n"; diff --git a/xr/sys/fdwrite.cc b/xr/sys/fdwrite.cc @@ -40,18 +40,17 @@ 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); + if (fd < 3) + nwritten = write (fd, buf + totwritten, buflen - totwritten); else - nwritten = send (fd, buf + totwritten, buflen - nwritten, 0); + nwritten = send (fd, buf + totwritten, buflen - totwritten, 0); # else - nwritten = write (fd, buf + totwritten, buflen - nwritten); + nwritten = write (fd, buf + totwritten, buflen - totwritten); # endif if (config.debug()) { ostringstream o; - o << "Sent " << static_cast<long>(nwritten) - << " bytes to fd " << fd << "\n"; + o << "Sent " << nwritten << " bytes to fd " << fd << "\n"; debugmsg (o.str()); } diff --git a/xr/tcpdispatcher/handle.cc b/xr/tcpdispatcher/handle.cc @@ -13,25 +13,35 @@ void TcpDispatcher::handle() { readset.add (clientfd()); readset.add (backendfd()); - int s; - if ((s = readset.readable()) < 0) + int sock; + if ((sock = readset.readable()) < 0) break; if (config.debug()) { ostringstream o; - o << s; + o << sock; debugmsg ("Data waiting on fd " + o.str() + "\n"); } - if (!readchunk (s == clientfd() ? clientfd(): backendfd())) + if (!readchunk (sock)) break; - // fdwrite (1, 0, databuf(), databufsize()); + int othersock, timeout; + if (sock == clientfd()) { + othersock = backendfd(); + timeout = config.backend_timeout(); + } else { + othersock = clientfd(); + timeout = config.client_timeout(); + } + + ostringstream o; + o << "Had data on " << sock << ", sending to " << othersock << "\n"; + debugmsg (o.str()); - fdwrite (s == clientfd() ? backendfd() : clientfd(), - s == clientfd() ? config.backend_timeout() : - config.client_timeout(), - databuf(), databufsize()); - balancer.backend(target_backend).addbytes(databufsize()); + fdwrite (othersock, timeout, databuf(), databufsize()); + + if (sock == backendfd()) + balancer.backend(target_backend).addbytes(databufsize()); } }