summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-09-06 11:09:16 +0100
committerCarl Hetherington <cth@carlh.net>2018-09-06 11:09:16 +0100
commitebc29bddd5cbc5cad23cc9b1095d842f55ece5e0 (patch)
tree7095d6d7cd9df042f80eb2952b666b57afc8cdc1
parent4d3d20687c9e334b29c8a2821e0646fb9166ab3f (diff)
Try to prevent encode server test crashing in valgrind.
-rw-r--r--src/lib/encode_server.cc7
-rw-r--r--src/lib/server.cc5
-rw-r--r--src/lib/server.h3
-rw-r--r--test/client_server_test.cc2
-rw-r--r--wscript1
5 files changed, 14 insertions, 4 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
diff --git a/test/client_server_test.cc b/test/client_server_test.cc
index 592a7e294..3ab1c36e1 100644
--- a/test/client_server_test.cc
+++ b/test/client_server_test.cc
@@ -50,7 +50,7 @@ void
do_remote_encode (shared_ptr<DCPVideo> frame, EncodeServerDescription description, Data locally_encoded)
{
Data remotely_encoded;
- BOOST_REQUIRE_NO_THROW (remotely_encoded = frame->encode_remotely (description, 60));
+ BOOST_REQUIRE_NO_THROW (remotely_encoded = frame->encode_remotely (description, 1200));
BOOST_REQUIRE_EQUAL (locally_encoded.size(), remotely_encoded.size());
BOOST_CHECK_EQUAL (memcmp (locally_encoded.data().get(), remotely_encoded.data().get(), locally_encoded.size()), 0);
diff --git a/wscript b/wscript
index 936e325e7..d6637f3f8 100644
--- a/wscript
+++ b/wscript
@@ -564,6 +564,7 @@ def configure(conf):
# Other stuff
conf.find_program('msgfmt', var='MSGFMT')
+ conf.check(header_name='valgrind/memcheck.h', mandatory=False)
datadir = conf.env.DATADIR
if not datadir: