From 4b34a4d950f762b5d020d5ac4d3354836833039c Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 21 May 2020 18:00:25 +0200 Subject: FCGI: Fix connection handling on broken pipe: Reopen new socket --- plugins/fcgi/fcgi.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'plugins/fcgi/fcgi.cpp') diff --git a/plugins/fcgi/fcgi.cpp b/plugins/fcgi/fcgi.cpp index 5a7ce65..7748845 100644 --- a/plugins/fcgi/fcgi.cpp +++ b/plugins/fcgi/fcgi.cpp @@ -357,7 +357,7 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context) std::lock_guard socket_lock{socket->getMutex()}; if (!socket->is_open()) { - //std::cout << "FCGI: Opening new socket" << std::endl; + std::cout << "FCGI: Opening new socket to " << app_addr << std::endl; socket->open(); opening = true; @@ -402,7 +402,12 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context) std::cerr << "Warning: Not all bytes written" << std::endl; } catch (const fcgi_eof_error&) { std::cerr << "FCGI Error: EOF on write" << std::endl; // seems to be ok here + m_sockets.erase(app_addr); // force new socket next time return HttpStatus("500", "FCGI connection: EOF on write", context.SetResponseHeader); + } catch (const fcgi_broken_pipe_error&) { + std::cerr << "FCGI Error: Broken pipe on write" << std::endl; // seems to be ok here + m_sockets.erase(app_addr); // force new socket next time + return HttpStatus("500", "FCGI connection: Broken pipe on write", context.SetResponseHeader); } #if 0 @@ -418,7 +423,8 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context) try { socket->read(inbuf); } catch (const fcgi_eof_error&) { - std::cerr << "FCGI Warning: Early EOF" << std::endl; // seems to be ok here + std::cerr << "FCGI Warning: Early EOF from application server. Break." << std::endl; // seems to be ok here + m_sockets.erase(app_addr); // force new socket next time ended = true; //return HttpStatus("500", "FCGI connection: EOF on read", context.SetResponseHeader); } -- cgit v1.2.3