From f49cd79ed8cdb1cb8988aad2cfa3f22d4866fb27 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 3 May 2020 09:25:38 +0200 Subject: FCGI: Fix multithreading for m_socket --- plugins/fcgi/fcgi.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'plugins/fcgi/fcgi.cpp') diff --git a/plugins/fcgi/fcgi.cpp b/plugins/fcgi/fcgi.cpp index b9e279f..416ca24 100644 --- a/plugins/fcgi/fcgi.cpp +++ b/plugins/fcgi/fcgi.cpp @@ -347,6 +347,9 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context) if (pos != app_addr.npos) { // host:port auto endpoints{m_resolver.resolve(app_addr.substr(0, pos), app_addr.substr(pos + 1))}; bool opening{false}; + + std::lock_guard socket_lock{m_socket_mutex}; + if (!m_socket.is_open()) { std::cout << "FCGI: Opening new socket" << std::endl; boost::asio::connect(m_socket, endpoints); @@ -434,8 +437,17 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context) } } } - } else { // Unix domain socket, or file to start + } else if (fs::is_socket(fs::path{app_addr})) { // Unix domain socket + // TODO + std::cerr << "FCGI Error: Unix domain sockets not yet implemented." << std::endl; + return HttpStatus("500", "FCGI configuration", context.SetResponseHeader); + } else if (fs::is_regular_file(fs::path{app_addr})) { // Executable to start // TODO + std::cerr << "FCGI Error: Executable FCGI not yet implemented." << std::endl; + return HttpStatus("500", "FCGI configuration", context.SetResponseHeader); + } else { + std::cerr << "FCGI Error: Invalid app_addr type." << std::endl; + return HttpStatus("500", "FCGI configuration", context.SetResponseHeader); } std::istringstream is_out{output_data}; -- cgit v1.2.3