From 6181651d0d4a33289297cbfb925f2765452767ba Mon Sep 17 00:00:00 2001 From: Rosen Matev <rosen.matev@cern.ch> Date: Fri, 19 Nov 2021 18:34:45 +0100 Subject: [PATCH 1/3] Fix pragma messages from Boost.bind --- .../GaudiOnlineTests/src/Asio_echo_server.cpp | 2 +- .../src/Asio_unix_socket_test.cpp | 2 +- .../src/asio_test_async_connect.cpp | 4 +- Online/OnlineBase/src/ASIO/TcpConnection.cpp | 10 +- Online/OnlineBase/src/ASIO/TcpServer.cpp | 8 +- Online/OnlineBase/src/ASIO/Transfer.cpp | 4 +- Online/OnlineBase/src/ASIO/UnixConnection.cpp | 10 +- Online/OnlineBase/src/ASIO/UnixServer.cpp | 6 +- Online/OnlineBase/src/ASIO/UnixTransfer.cpp | 2 + Online/Presenter/src/ProblemDB.cpp | 111 +++++++++--------- Online/Presenter/src/ShiftDB.cpp | 77 ++++++------ 11 files changed, 120 insertions(+), 116 deletions(-) diff --git a/Online/GaudiOnlineTests/src/Asio_echo_server.cpp b/Online/GaudiOnlineTests/src/Asio_echo_server.cpp index b42c5f663..ef7934c95 100755 --- a/Online/GaudiOnlineTests/src/Asio_echo_server.cpp +++ b/Online/GaudiOnlineTests/src/Asio_echo_server.cpp @@ -12,7 +12,7 @@ #include <thread> #include <cstdlib> #include <iostream> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/smart_ptr.hpp> #include <boost/asio.hpp> diff --git a/Online/GaudiOnlineTests/src/Asio_unix_socket_test.cpp b/Online/GaudiOnlineTests/src/Asio_unix_socket_test.cpp index 335870fbe..128184686 100755 --- a/Online/GaudiOnlineTests/src/Asio_unix_socket_test.cpp +++ b/Online/GaudiOnlineTests/src/Asio_unix_socket_test.cpp @@ -11,7 +11,7 @@ #include <cstdio> #include <iostream> #include <boost/array.hpp> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/shared_ptr.hpp> #include <boost/asio.hpp> diff --git a/Online/GaudiOnlineTests/src/asio_test_async_connect.cpp b/Online/GaudiOnlineTests/src/asio_test_async_connect.cpp index dd9aefb40..fab846999 100644 --- a/Online/GaudiOnlineTests/src/asio_test_async_connect.cpp +++ b/Online/GaudiOnlineTests/src/asio_test_async_connect.cpp @@ -14,7 +14,7 @@ #include <boost/asio/buffer.hpp> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/placeholders.hpp> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <array> #include <string> #include <iostream> @@ -76,7 +76,7 @@ extern "C" int asio_test_async_connect(int argc, char** argv) { asio::ip::tcp::resolver::query query{ node, port}; resolv.async_resolve(query, std::bind(&Async::resolve_handler, - &handler, + &handler, std::placeholders::_1, std::placeholders::_2)); ioservice.run(); diff --git a/Online/OnlineBase/src/ASIO/TcpConnection.cpp b/Online/OnlineBase/src/ASIO/TcpConnection.cpp index 2731a4c1c..da9c4fc51 100755 --- a/Online/OnlineBase/src/ASIO/TcpConnection.cpp +++ b/Online/OnlineBase/src/ASIO/TcpConnection.cpp @@ -20,7 +20,7 @@ // System / Boost include files #include <memory> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/version.hpp> namespace asio { @@ -30,7 +30,7 @@ namespace asio { using namespace BoostAsio; /// Construct a connection with the given io_service. -TcpConnection::TcpConnection(asio::io_service& io_service, +TcpConnection::TcpConnection(asio::io_service& io_service, TcpRequestHandler::pointer_t& handler) : m_strand(io_service), m_socket(io_service), m_handler(handler), m_param(0) { @@ -69,7 +69,7 @@ void TcpConnection::shutdown() { } /// Handle completion of a optional asynchonous unlocked read operation. -void TcpConnection::handle_additional_read(const error_t& /* error */, +void TcpConnection::handle_additional_read(const error_t& /* error */, size_t /* bytes_transferred */) { } @@ -81,7 +81,7 @@ SyncTcpConnection::SyncTcpConnection(boost::asio::io_service& io_service, { m_recv_buffer.resize(recvSize); } - + /// Default destructor SyncTcpConnection::~SyncTcpConnection() { } @@ -149,7 +149,7 @@ AsyncTcpConnection::AsyncTcpConnection(boost::asio::io_service& io_service, { m_recv_buffer.resize(recvSize/* +1024 */); } - + /// Default destructor AsyncTcpConnection::~AsyncTcpConnection() { } diff --git a/Online/OnlineBase/src/ASIO/TcpServer.cpp b/Online/OnlineBase/src/ASIO/TcpServer.cpp index e112ab9df..539e7e241 100755 --- a/Online/OnlineBase/src/ASIO/TcpServer.cpp +++ b/Online/OnlineBase/src/ASIO/TcpServer.cpp @@ -21,7 +21,7 @@ // System / Boost include files #include <thread> #include <memory> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/lexical_cast.hpp> namespace asio { @@ -31,7 +31,7 @@ namespace asio { using namespace BoostAsio; /// Default constructor -TcpServerConfig::TcpServerConfig(TcpServer* srv) +TcpServerConfig::TcpServerConfig(TcpServer* srv) : m_server(srv), handler(), recvSize(8192), synchronous(1) { } @@ -54,7 +54,7 @@ TcpConnection* TcpServerConfig::newConnection() { /// Construct the server to listen on the specified TCP address and port TcpServer::TcpServer(const std::string& address, const std::string& port, size_t num_threads) - : m_numThreads(num_threads),m_service(), + : m_numThreads(num_threads),m_service(), m_signals(m_service), m_acceptor(m_service), m_newConnection(), config() { @@ -63,7 +63,7 @@ TcpServer::TcpServer(const std::string& address, const std::string& port, size_t // It is safe to register for the same signal multiple times in a program, // provided all registration for the specified signal is made through Asio. config->handler.reset(new TcpRequestHandler()); - + // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR). asio::ip::tcp::resolver resolver(m_service); asio::ip::tcp::resolver::query query(address, port); diff --git a/Online/OnlineBase/src/ASIO/Transfer.cpp b/Online/OnlineBase/src/ASIO/Transfer.cpp index b080b3d81..49e797ce6 100755 --- a/Online/OnlineBase/src/ASIO/Transfer.cpp +++ b/Online/OnlineBase/src/ASIO/Transfer.cpp @@ -112,7 +112,7 @@ namespace TRANSFER_NS { #include "NET/defs.h" #include "ASIO/TanInterface.h" //#include "TAN/TanInterface.h" -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> namespace TRANSFER_NS { @@ -159,7 +159,7 @@ namespace TRANSFER_NS { else if ( ec == asio::error::eof ) { ::lib_rtl_output(net->m_cancelled ? LIB_RTL_DEBUG : LIB_RTL_ERROR, "ASIO: Recv EOF. Incomplete header. %d < %d bytes. %d [%s] Cancelled:%s %s", - len, sizeof(netheader_t), ec.value(), ec.message().c_str(), + len, sizeof(netheader_t), ec.value(), ec.message().c_str(), RTL::yes_no(net->m_cancelled), this->entry ? this->entry->header.name : ""); if ( net->m_cancelled ) { if ( this->entry ) { diff --git a/Online/OnlineBase/src/ASIO/UnixConnection.cpp b/Online/OnlineBase/src/ASIO/UnixConnection.cpp index aa0b14344..fec0380e2 100755 --- a/Online/OnlineBase/src/ASIO/UnixConnection.cpp +++ b/Online/OnlineBase/src/ASIO/UnixConnection.cpp @@ -20,7 +20,7 @@ // System / Boost include files #include <memory> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> namespace asio { using namespace boost::asio; @@ -29,7 +29,7 @@ namespace asio { using namespace BoostAsio; /// Construct a connection with the given io_service. -UnixConnection::UnixConnection(asio::io_service& io_service, +UnixConnection::UnixConnection(asio::io_service& io_service, UnixRequestHandler::pointer_t& handler) : m_strand(io_service), m_socket(io_service), m_handler(handler), m_param(0) { @@ -58,7 +58,7 @@ void UnixConnection::shutdown() { } /// Handle completion of a optional asynchonous unlocked read operation. -void UnixConnection::handle_additional_read(const error_t& /* error */, +void UnixConnection::handle_additional_read(const error_t& /* error */, size_t /* bytes_transferred */) { } @@ -70,7 +70,7 @@ SyncUnixConnection::SyncUnixConnection(boost::asio::io_service& io_service, { m_recv_buffer.resize(recvSize); } - + /// Default destructor SyncUnixConnection::~SyncUnixConnection() { } @@ -138,7 +138,7 @@ AsyncUnixConnection::AsyncUnixConnection(boost::asio::io_service& io_service, { m_recv_buffer.resize(recvSize); } - + /// Default destructor AsyncUnixConnection::~AsyncUnixConnection() { } diff --git a/Online/OnlineBase/src/ASIO/UnixServer.cpp b/Online/OnlineBase/src/ASIO/UnixServer.cpp index cb3d37374..430e9e296 100755 --- a/Online/OnlineBase/src/ASIO/UnixServer.cpp +++ b/Online/OnlineBase/src/ASIO/UnixServer.cpp @@ -21,7 +21,7 @@ // System / Boost include files #include <thread> #include <memory> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/lexical_cast.hpp> namespace asio { @@ -31,7 +31,7 @@ namespace asio { using namespace BoostAsio; /// Default constructor -UnixServerConfig::UnixServerConfig(UnixServer* srv) +UnixServerConfig::UnixServerConfig(UnixServer* srv) : m_server(srv), handler(), recvSize(8192), synchronous(1) { } @@ -54,7 +54,7 @@ UnixConnection* UnixServerConfig::newConnection() { /// Construct the server to listen on the specified TCP address and port UnixServer::UnixServer(const std::string& file, size_t num_threads) - : m_numThreads(num_threads),m_service(), + : m_numThreads(num_threads),m_service(), m_signals(m_service), m_acceptor(m_service, asio::local::stream_protocol::endpoint(file)), m_newConnection(), config() { diff --git a/Online/OnlineBase/src/ASIO/UnixTransfer.cpp b/Online/OnlineBase/src/ASIO/UnixTransfer.cpp index fe851f70b..d47d41044 100755 --- a/Online/OnlineBase/src/ASIO/UnixTransfer.cpp +++ b/Online/OnlineBase/src/ASIO/UnixTransfer.cpp @@ -19,7 +19,9 @@ namespace BoostAsio { typedef class UnixRequestHandler TransferRequestHandler; typedef class UnixServerConfig TransferServerConfig; } +#define BOOST_DISABLE_PRAGMA_MESSAGE #include "ASIO/Boost.h" +#undef BOOST_DISABLE_PRAGMA_MESSAGE namespace TRANSFER_NS { typedef boost::system::error_code error_t; } diff --git a/Online/Presenter/src/ProblemDB.cpp b/Online/Presenter/src/ProblemDB.cpp index b13ebf446..a54ef421c 100755 --- a/Online/Presenter/src/ProblemDB.cpp +++ b/Online/Presenter/src/ProblemDB.cpp @@ -6,7 +6,7 @@ #include <iostream> // Boost -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/gregorian/formatters.hpp> @@ -26,20 +26,21 @@ public: // -1 as run number means "get system list" // -2 means post entry - presenter_ssl_client_pbdb(boost::asio::io_service& io_service, boost::asio::ssl::context& context, - boost::asio::ip::tcp::resolver::iterator endpoint_iterator , - std::stringstream * theStream , - int runNumber , + presenter_ssl_client_pbdb(boost::asio::io_service& io_service, boost::asio::ssl::context& context, + boost::asio::ip::tcp::resolver::iterator endpoint_iterator , + std::stringstream * theStream , + int runNumber , std::string * args = 0 ) - : socket_(io_service, context) , m_stream( theStream ) , m_runNumber( runNumber ) , m_args( args ) + : socket_(io_service, context) , m_stream( theStream ) , m_runNumber( runNumber ) , m_args( args ) { + using namespace boost::placeholders; socket_.set_verify_mode(boost::asio::ssl::context::verify_none); socket_.set_verify_callback(boost::bind(&presenter_ssl_client_pbdb::verify_certificate, this, _1, _2)); - boost::asio::async_connect(socket_.lowest_layer(), endpoint_iterator, - boost::bind(&presenter_ssl_client_pbdb::handle_connect, this, + boost::asio::async_connect(socket_.lowest_layer(), endpoint_iterator, + boost::bind(&presenter_ssl_client_pbdb::handle_connect, this, boost::asio::placeholders::error)); } - + bool verify_certificate(bool preverified, boost::asio::ssl::verify_context& /* ctx */) { //char subject_name[256]; @@ -48,18 +49,18 @@ public: //std::cout << "Verifying:\n" << subject_name << std::endl; return preverified; } - + void handle_connect(const boost::system::error_code& error) { if(!error){ - socket_.async_handshake(boost::asio::ssl::stream_base::client, - boost::bind(&presenter_ssl_client_pbdb::handle_handshake, this, + socket_.async_handshake(boost::asio::ssl::stream_base::client, + boost::bind(&presenter_ssl_client_pbdb::handle_handshake, this, boost::asio::placeholders::error)); }else{ std::cout << "Connect failed: " << error.message() << std::endl; } } - + void handle_handshake(const boost::system::error_code& error ) { if(!error){ @@ -67,43 +68,43 @@ public: // get systems if ( -1 == m_runNumber ) { - request_ << "GET /api/systems/ HTTP/1.0\r\n" - << "Host: lbproblems.cern.ch\r\n" + request_ << "GET /api/systems/ HTTP/1.0\r\n" + << "Host: lbproblems.cern.ch\r\n" << "Accept: */*\r\n" << "Connection: close\r\n\r\n"; } - else if ( -2 == m_runNumber ) { - char argLen[20] ; + else if ( -2 == m_runNumber ) { + char argLen[20] ; sprintf( argLen , "%d" , (int) m_args -> size() ) ; request_ << "POST /api/problems/ HTTP/1.0\r\n" << "Host: lbproblems.cern.ch\r\n" - << "Content-Length: " << argLen + << "Content-Length: " << argLen << "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n" ; - if ( 0 != m_args ) + if ( 0 != m_args ) request_ << (*m_args) ; request_ << "\r\nAccept: */*\r\n" - << "Connection: close\r\n\r\n"; + << "Connection: close\r\n\r\n"; } - else { - // get problem list + else { + // get problem list request_ << "GET /api/search/?_inline=True&system_visible=True" ; if ( 0 == m_runNumber ) { boost::posix_time::ptime now = boost::posix_time::second_clock::local_time() ; boost::gregorian::date day = now.date() + boost::gregorian::date_duration( 1 ) ; - - request_ << "&open_or_closed_gte=" << boost::gregorian::to_iso_extended_string( day ) - << " HTTP/1.0\r\n" - << "Host: lbproblems.cern.ch\r\n" + + request_ << "&open_or_closed_gte=" << boost::gregorian::to_iso_extended_string( day ) + << " HTTP/1.0\r\n" + << "Host: lbproblems.cern.ch\r\n" << "Accept: */*\r\n" << "Connection: close\r\n\r\n"; } else { RunDB runDb( "lbrundb.cern.ch" ) ; if ( ! runDb.checkRun( m_runNumber ) ) { - std::cerr << "Run number " << m_runNumber << "was not found in db" + std::cerr << "Run number " << m_runNumber << "was not found in db" << std::endl ; return ; } @@ -115,32 +116,32 @@ public: << "&started_lte=" << et << " HTTP/1.0\r\n" << "Host: lbproblems.cern.ch\r\n" - << "Accept: */*\r\n" + << "Accept: */*\r\n" << "Connection: close\r\n\r\n" ; } } - boost::asio::async_write(socket_, boost::asio::buffer(request_.str()), - boost::bind(&presenter_ssl_client_pbdb::handle_write, this, - boost::asio::placeholders::error, + boost::asio::async_write(socket_, boost::asio::buffer(request_.str()), + boost::bind(&presenter_ssl_client_pbdb::handle_write, this, + boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } else { std::cout << "Handshake failed: " << error.message() << std::endl; } } - + void handle_write(const boost::system::error_code& error, size_t bytes_transferred) { if (!error){ boost::asio::async_read(socket_, boost::asio::buffer(reply_, bytes_transferred), - boost::asio::transfer_at_least(1), - boost::bind(&presenter_ssl_client_pbdb::handle_read, this, - boost::asio::placeholders::error, + boost::asio::transfer_at_least(1), + boost::bind(&presenter_ssl_client_pbdb::handle_read, this, + boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } else { std::cout << "Write failed: " << error.message() << std::endl; } } - + void handle_read(const boost::system::error_code& error, size_t bytes_transferred) { if (!error){ @@ -154,12 +155,12 @@ public: boost::asio::placeholders::bytes_transferred)); } } - + private: boost::asio::ssl::stream<boost::asio::ip::tcp::socket> socket_; char reply_[0x1 << 16]; std::stringstream * m_stream ; - int m_runNumber ; + int m_runNumber ; std::string * m_args ; }; @@ -184,7 +185,7 @@ ProblemDB::ProblemDB( std::string address, std::string rundbAddress ) { } getSystems(); - + m_rundbAddress = rundbAddress; } @@ -218,13 +219,13 @@ int ProblemDB::post( std::string system, std::string username, std::string title std::string hostName = "lbproblems.cern.ch"; std::stringstream web_stream ; - try { + try { boost::asio::io_service io_service ; - + boost::asio::ip::tcp::resolver resolver(io_service); boost::asio::ip::tcp::resolver::query query(hostName, "https"); boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query); - + boost::asio::ssl::context context(boost::asio::ssl::context::sslv23); // Arguments for posting to problem db @@ -238,7 +239,7 @@ int ProblemDB::post( std::string system, std::string username, std::string title // -2 as run number means : POST presenter_ssl_client_pbdb c(io_service, context, iterator, &web_stream , -2 , &postArg ); - + io_service.run(); } catch (std::exception& e){ std::cerr << "Exception: " << e.what() << "\n"; @@ -260,7 +261,7 @@ int ProblemDB::post( std::string system, std::string username, std::string title } else { m_reference = line; } - + return status; } //========================================================================= @@ -295,21 +296,21 @@ std::string ProblemDB::urlEncode ( std::string src) { std::vector< std::vector< std::string > > ProblemDB::listOfProblems( const std::string & systemName , int runNumber ) { std::vector< std::vector< std::string > > problems; - + std::string hostName = "lbproblems.cern.ch"; std::stringstream web_stream ; - try { + try { boost::asio::io_service io_service ; - + boost::asio::ip::tcp::resolver resolver(io_service); boost::asio::ip::tcp::resolver::query query(hostName, "https"); boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query); - + boost::asio::ssl::context context(boost::asio::ssl::context::sslv23); presenter_ssl_client_pbdb c(io_service, context, iterator, &web_stream , runNumber ); - + io_service.run(); }catch (std::exception& e){ std::cerr << "Exception: " << e.what() << "\n"; @@ -317,7 +318,7 @@ std::vector< std::vector< std::string > > ProblemDB::listOfProblems( const std:: } std::string line ; - + // Check that the web server answers correctly std::getline( web_stream , line ) ; if ( ! boost::algorithm::find_first( line , "200 OK" ) ) { @@ -325,7 +326,7 @@ std::vector< std::vector< std::string > > ProblemDB::listOfProblems( const std:: std::cout << line << std::endl ; return problems ; } - + // Parse the web server answers std::string pattern ; pattern = "\\N{left-square-bracket}\\N{left-curly-bracket}(.*)" ; @@ -376,18 +377,18 @@ void ProblemDB::getSystems ( ) { std::string hostName = "lbproblems.cern.ch"; std::stringstream web_stream ; - try { + try { boost::asio::io_service io_service ; - + boost::asio::ip::tcp::resolver resolver(io_service); boost::asio::ip::tcp::resolver::query query(hostName, "https"); boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query); - + boost::asio::ssl::context context(boost::asio::ssl::context::sslv23); // -1 as run number means : get system list presenter_ssl_client_pbdb c(io_service, context, iterator, &web_stream , -1 ); - + io_service.run(); } catch (std::exception& e){ std::cerr << "Exception: " << e.what() << "\n"; diff --git a/Online/Presenter/src/ShiftDB.cpp b/Online/Presenter/src/ShiftDB.cpp index eb8326d38..a892e710f 100755 --- a/Online/Presenter/src/ShiftDB.cpp +++ b/Online/Presenter/src/ShiftDB.cpp @@ -7,7 +7,7 @@ #include <iostream> // Boost -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include "boost/date_time/posix_time/posix_time_types.hpp" #include "boost/date_time/gregorian/formatters.hpp" #include <boost/asio.hpp> @@ -22,18 +22,19 @@ class presenter_ssl_client { public: - presenter_ssl_client(boost::asio::io_service& io_service, boost::asio::ssl::context& context, - boost::asio::ip::tcp::resolver::iterator endpoint_iterator , + presenter_ssl_client(boost::asio::io_service& io_service, boost::asio::ssl::context& context, + boost::asio::ip::tcp::resolver::iterator endpoint_iterator , const boost::gregorian::date * day , std::stringstream * theStream ) : socket_(io_service, context), m_day( day ) , m_stream( theStream ) { + using namespace boost::placeholders; socket_.set_verify_mode(boost::asio::ssl::context::verify_none); socket_.set_verify_callback(boost::bind(&presenter_ssl_client::verify_certificate, this, _1, _2)); - boost::asio::async_connect(socket_.lowest_layer(), endpoint_iterator, - boost::bind(&presenter_ssl_client::handle_connect, this, + boost::asio::async_connect(socket_.lowest_layer(), endpoint_iterator, + boost::bind(&presenter_ssl_client::handle_connect, this, boost::asio::placeholders::error)); } - + bool verify_certificate(bool preverified, boost::asio::ssl::verify_context& /*ctx*/) { //char subject_name[256]; @@ -42,52 +43,52 @@ public: //std::cout << "Verifying:\n" << subject_name << std::endl; return preverified; } - + void handle_connect(const boost::system::error_code& error) { if(!error){ - socket_.async_handshake(boost::asio::ssl::stream_base::client, - boost::bind(&presenter_ssl_client::handle_handshake, this, + socket_.async_handshake(boost::asio::ssl::stream_base::client, + boost::bind(&presenter_ssl_client::handle_handshake, this, boost::asio::placeholders::error)); }else{ std::cout << "Connect failed: " << error.message() << std::endl; } } - + void handle_handshake(const boost::system::error_code& error ) { if(!error){ std::stringstream request_; - + request_ << "GET /shiftdb_report.php?format=twiki&" - << "sDate=" << boost::gregorian::to_iso_string( *m_day ) - << " HTTP/1.0\r\n" - << "Host: lbshiftdb.cern.ch\r\n" + << "sDate=" << boost::gregorian::to_iso_string( *m_day ) + << " HTTP/1.0\r\n" + << "Host: lbshiftdb.cern.ch\r\n" << "Accept: */*\r\n" << "Connection: close\r\n\r\n"; - boost::asio::async_write(socket_, boost::asio::buffer(request_.str()), - boost::bind(&presenter_ssl_client::handle_write, this, - boost::asio::placeholders::error, + boost::asio::async_write(socket_, boost::asio::buffer(request_.str()), + boost::bind(&presenter_ssl_client::handle_write, this, + boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } else { std::cout << "Handshake failed: " << error.message() << std::endl; } } - + void handle_write(const boost::system::error_code& error, size_t bytes_transferred) { if (!error){ boost::asio::async_read(socket_, boost::asio::buffer(reply_, bytes_transferred), - boost::asio::transfer_at_least(1), - boost::bind(&presenter_ssl_client::handle_read, this, - boost::asio::placeholders::error, + boost::asio::transfer_at_least(1), + boost::bind(&presenter_ssl_client::handle_read, this, + boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } else { std::cout << "Write failed: " << error.message() << std::endl; } } - + void handle_read(const boost::system::error_code& error, size_t bytes_transferred) { if (!error){ @@ -101,7 +102,7 @@ public: boost::asio::placeholders::bytes_transferred)); } } - + private: boost::asio::ssl::stream<boost::asio::ip::tcp::socket> socket_; char reply_[0x1 << 16]; @@ -137,16 +138,16 @@ void ShiftDB::readWebFile( const boost::gregorian::date * day ) { try{ boost::asio::io_service io_service; - + boost::asio::ip::tcp::resolver resolver(io_service); boost::asio::ip::tcp::resolver::query query(hostName, "https"); boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query); - + boost::asio::ssl::context context(boost::asio::ssl::context::sslv23); //context.load_verify_file("key.pem"); - + presenter_ssl_client c(io_service, context, iterator, day, &web_stream); - + io_service.run(); }catch (std::exception& e){ std::cerr << "Exception: " << e.what() << "\n"; @@ -162,7 +163,7 @@ void ShiftDB::readWebFile( const boost::gregorian::date * day ) { m_open = false ; return ; } - + // Parse the answer of the web server with | as separator boost::char_separator< char > sep( "|" , "" , boost::keep_empty_tokens ) ; boost::tokenizer< boost::char_separator< char > > tok( line , sep ) ; @@ -172,7 +173,7 @@ void ShiftDB::readWebFile( const boost::gregorian::date * day ) { pattern = "\\N{vertical-line}(.*)" ; pattern += "\\N{vertical-line}(.*)" ; pattern += "\\N{vertical-line}(.*)" ; - pattern += "\\N{vertical-line}(.*)" ; + pattern += "\\N{vertical-line}(.*)" ; pattern += "\\N{vertical-line}(.*)" ; pattern += "\\N{vertical-line}(.*)" ; pattern += "\\N{vertical-line}" ; @@ -190,14 +191,14 @@ void ShiftDB::readWebFile( const boost::gregorian::date * day ) { std::string function = (*it) ; ++it ; // Remove spaces before and after boost::algorithm::trim_left_if( function , boost::algorithm::is_space() ) ; - boost::algorithm::trim_right_if( function , + boost::algorithm::trim_right_if( function , boost::algorithm::is_space() ) ; // Get Names std::vector< std::string > vec ; vec.push_back( *(++it ) ) ; vec.push_back( *(++it ) ) ; vec.push_back( *(++it ) ) ; - + m_shifters[ function ] = vec ; } @@ -205,16 +206,16 @@ void ShiftDB::readWebFile( const boost::gregorian::date * day ) { } //============================================================================= -// Get name of the person on shift for a given function and a given slot +// Get name of the person on shift for a given function and a given slot //============================================================================= -std::string ShiftDB::getShifter( const std::string & function , - const int slot ) { +std::string ShiftDB::getShifter( const std::string & function , + const int slot ) { if ( ! m_open ) return function ; - if ( m_shifters.find( function ) == m_shifters.end() ) + if ( m_shifters.find( function ) == m_shifters.end() ) return function ; - return m_shifters[ function ][ slot ] ; + return m_shifters[ function ][ slot ] ; } //============================================================================= @@ -222,7 +223,7 @@ std::string ShiftDB::getShifter( const std::string & function , //============================================================================= std::string ShiftDB::getCurrentDataManager( ) { - boost::posix_time::ptime now = + boost::posix_time::ptime now = boost::posix_time::second_clock::local_time() ; boost::gregorian::date now_day = now.date() ; @@ -249,7 +250,7 @@ std::string ShiftDB::getCurrentDataManager( ) { //============================================================================= std::string ShiftDB::getDQPiquet( ) { - boost::posix_time::ptime now = + boost::posix_time::ptime now = boost::posix_time::second_clock::local_time() ; boost::gregorian::date now_day = now.date() ; -- GitLab From 2db4e18b124cf67e5f4785a8a4cae91323053d8a Mon Sep 17 00:00:00 2001 From: Rosen Matev <rosen.matev@cern.ch> Date: Fri, 19 Nov 2021 18:42:32 +0100 Subject: [PATCH 2/3] Fix clang warnings --- Online/GauchoAppl/src/components/BusySvc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Online/GauchoAppl/src/components/BusySvc.cpp b/Online/GauchoAppl/src/components/BusySvc.cpp index abd0ee581..1813c24cc 100644 --- a/Online/GauchoAppl/src/components/BusySvc.cpp +++ b/Online/GauchoAppl/src/components/BusySvc.cpp @@ -76,19 +76,19 @@ StatusCode BusySvc::initialize() { m_monitorSvc->declareInfo("BogoMIPS",m_bogus,"",this); m_monitorSvc->declareInfo("busyFraction",m_busybogus,"",this); m_monitorSvc->declareInfo("NumCores",m_numCores,"",this); - + m_monitorSvc->declareInfo("TotMemory",m_memtot,"",this); m_monitorSvc->declareInfo("FreeMemory",m_memfree,"",this); m_monitorSvc->declareInfo("MemBuffers",m_membuff,"",this); m_monitorSvc->declareInfo("SwapSpaceTot",m_memSwaptot,"",this); m_monitorSvc->declareInfo("SwapSpaceFree",m_memSwapfree,"",this); m_monitorSvc->declareInfo("MemAvail",m_memAvail,"",this); - + m_monitorSvc->declareInfo(node_class+"/IdleFraction",m_idlebogus,"",this); m_monitorSvc->declareInfo(node_class+"/BogoMIPS",m_bogus,"",this); m_monitorSvc->declareInfo(node_class+"/busyFraction",m_busybogus,"",this); m_monitorSvc->declareInfo(node_class+"/NumCores",m_numCores,"",this); - + m_monitorSvc->declareInfo(node_class+"/TotMemory",m_memtot,"",this); m_monitorSvc->declareInfo(node_class+"/FreeMemory",m_memfree,"",this); m_monitorSvc->declareInfo(node_class+"/MemBuffers",m_membuff,"",this); -- GitLab From ab5e2b745c1583ccaae38237ec06621f6a6efa02 Mon Sep 17 00:00:00 2001 From: Rosen Matev <rosen.matev@cern.ch> Date: Fri, 19 Nov 2021 21:19:13 +0100 Subject: [PATCH 3/3] Improve optional build of Online/EventBuilding --- Online/EventBuilding/CMakeLists.txt | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Online/EventBuilding/CMakeLists.txt b/Online/EventBuilding/CMakeLists.txt index 6e487e904..02ce694f6 100644 --- a/Online/EventBuilding/CMakeLists.txt +++ b/Online/EventBuilding/CMakeLists.txt @@ -23,22 +23,30 @@ gaudi_depends_on_subdirs(Online/Dataflow # TODO use find_package for PCIe40 libs #Check for local PCIE40.If not present do not build event builder libraries -# TODO no cache is currently no supported by CMake < 3.21 check what it does in the future -find_path(PCIE40_DAQ_INC NAMES "daq40.hpp" "daq.h" "id.h" PATHS /usr/include/lhcb/daq40 NO_CACHE) +# TODO NO_CACHE is currently no supported by CMake < 3.21 check what it does in the future +find_path(PCIE40_DAQ_INC NAMES "daq40.hpp" "daq.h" "id.h" PATHS /usr/include/lhcb/daq40) if ( "${PCIE40_DAQ_INC}" STREQUAL "PCIE40_DAQ_INC-NOTFOUND" ) message(STATUS "+======================================================================+") message(STATUS "| PCIE40 DAQ not present. Will not build EventBuilding libraries. |") message(STATUS "+======================================================================+") return() -else() - return() +endif() + +find_package(MPI COMPONENTS CXX) +if(NOT MPI_CXX_FOUND) + # When not found there is the following red herring, + # see https://gitlab.kitware.com/cmake/cmake/-/issues/21491 + # + # -- Could NOT find MPI (missing: MPI_CXX_FOUND CXX) + # Reason given by package: MPI component 'Fortran' was requested, but language Fortran is not enabled. + # message(STATUS "+======================================================================+") - message(STATUS "| PCIE40 DAQ found. EventBuilding libraries shall be built. |") + message(STATUS "| MPI not present. Will not build EventBuilding libraries. |") message(STATUS "+======================================================================+") + return() endif() #fpisani fixed find of external libraries -find_package(MPI REQUIRED) include(Numa) find_package(PkgConfig REQUIRED) -- GitLab