diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-09-06 11:09:16 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-09-06 11:09:16 +0100 |
| commit | ebc29bddd5cbc5cad23cc9b1095d842f55ece5e0 (patch) | |
| tree | 7095d6d7cd9df042f80eb2952b666b57afc8cdc1 /src/lib | |
| parent | 4d3d20687c9e334b29c8a2821e0646fb9166ab3f (diff) | |
Try to prevent encode server test crashing in valgrind.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/encode_server.cc | 7 | ||||
| -rw-r--r-- | src/lib/server.cc | 5 | ||||
| -rw-r--r-- | src/lib/server.h | 3 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/lib/encode_server.cc b/src/lib/encode_server.cc index 26ef45d60..2603732c8 100644 --- a/src/lib/encode_server.cc +++ b/src/lib/encode_server.cc @@ -41,6 +41,9 @@ #include <boost/algorithm/string.hpp> #include <boost/scoped_array.hpp> #include <boost/foreach.hpp> +#ifdef HAVE_VALGRIND_H +#include <valgrind/memcheck.h> +#endif #include <string> #include <vector> #include <iostream> @@ -68,7 +71,11 @@ using dcp::Data; using dcp::raw_convert; EncodeServer::EncodeServer (shared_ptr<Log> log, bool verbose, int num_threads) +#if !defined(RUNNING_ON_VALGRIND) || RUNNING_ON_VALGRIND == 0 : Server (ENCODE_FRAME_PORT) +#else + : Server (ENCODE_FRAME_PORT, 2400) +#endif , _log (log) , _verbose (verbose) , _num_threads (num_threads) diff --git a/src/lib/server.cc b/src/lib/server.cc index 722b1c811..9a633c861 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -25,9 +25,10 @@ using boost::shared_ptr; -Server::Server (int port) +Server::Server (int port, int timeout) : _terminate (false) , _acceptor (_io_service, boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), port)) + , _timeout (timeout) { } @@ -60,7 +61,7 @@ Server::start_accept () } } - shared_ptr<Socket> socket (new Socket); + shared_ptr<Socket> socket (new Socket(_timeout)); _acceptor.async_accept (socket->socket (), boost::bind (&Server::handle_accept, this, socket, boost::asio::placeholders::error)); } diff --git a/src/lib/server.h b/src/lib/server.h index 795227523..59722274e 100644 --- a/src/lib/server.h +++ b/src/lib/server.h @@ -31,7 +31,7 @@ class Socket; class Server : public boost::noncopyable { public: - explicit Server (int port); + explicit Server (int port, int timeout = 30); virtual ~Server (); virtual void run (); @@ -49,6 +49,7 @@ private: boost::asio::io_service _io_service; boost::asio::ip::tcp::acceptor _acceptor; + int _timeout; }; #endif |
