+2018-04-13 Carl Hetherington <cth@carlh.net>
+
+ * Add servers with bad server-link versions in the list (#982).
+
2018-04-12 Carl Hetherington <cth@carlh.net>
* Prevent error when starting export without specifying a filename (#1260).
EncodeServerDescription ()
: _host_name ("")
, _threads (1)
+ , _link_version (0)
{}
/** @param h Server host name or IP address in string form.
* @param t Number of threads to use on the server.
+ * @param l Server link version number of the server.
*/
- EncodeServerDescription (std::string h, int t)
+ EncodeServerDescription (std::string h, int t, int l)
: _host_name (h)
, _threads (t)
+ , _link_version (l)
{}
/* Default copy constructor is fine */
return _threads;
}
+ int link_version () const {
+ return _link_version;
+ }
+
void set_host_name (std::string n) {
_host_name = n;
}
std::string _host_name;
/** number of threads to use on the server */
int _threads;
+ /** server link (i.e. protocol) version number */
+ int _link_version;
};
#endif
_listen_thread = 0;
boost::mutex::scoped_lock lm (_servers_mutex);
- _servers.clear ();
+ _good_servers.clear ();
+ _bad_servers.clear ();
}
void
xml->read_string (s);
string const ip = socket->socket().remote_endpoint().address().to_string ();
- if (!server_found (ip) && xml->optional_number_child<int>("Version").get_value_or (0) == SERVER_LINK_VERSION) {
- EncodeServerDescription sd (ip, xml->number_child<int> ("Threads"));
- {
+ if (!server_found (ip)) {
+ EncodeServerDescription sd (ip, xml->number_child<int>("Threads"), xml->optional_number_child<int>("Version").get_value_or(0));
+ if (sd.link_version() == SERVER_LINK_VERSION) {
+ boost::mutex::scoped_lock lm (_servers_mutex);
+ _good_servers.push_back (sd);
+ } else {
boost::mutex::scoped_lock lm (_servers_mutex);
- _servers.push_back (sd);
+ _bad_servers.push_back (sd);
}
emit (boost::bind (boost::ref (ServersListChanged)));
}
EncodeServerFinder::server_found (string ip) const
{
boost::mutex::scoped_lock lm (_servers_mutex);
- list<EncodeServerDescription>::const_iterator i = _servers.begin();
- while (i != _servers.end() && i->host_name() != ip) {
+ list<EncodeServerDescription>::const_iterator i = _good_servers.begin();
+ while (i != _good_servers.end() && i->host_name() != ip) {
+ ++i;
+ }
+
+ if (i != _good_servers.end()) {
+ return true;
+ }
+
+ i = _bad_servers.begin();
+ while (i != _bad_servers.end() && i->host_name() != ip) {
++i;
}
- return i != _servers.end ();
+ return i != _bad_servers.end ();
}
EncodeServerFinder*
}
list<EncodeServerDescription>
-EncodeServerFinder::servers () const
+EncodeServerFinder::good_servers () const
+{
+ boost::mutex::scoped_lock lm (_servers_mutex);
+ return _good_servers;
+}
+
+list<EncodeServerDescription>
+EncodeServerFinder::bad_servers () const
{
boost::mutex::scoped_lock lm (_servers_mutex);
- return _servers;
+ return _bad_servers;
}
void
if (what == Config::USE_ANY_SERVERS || what == Config::SERVERS) {
{
boost::mutex::scoped_lock lm (_servers_mutex);
- _servers.clear ();
+ _good_servers.clear ();
+ _bad_servers.clear ();
}
ServersListChanged ();
_search_condition.notify_all ();
void stop ();
- std::list<EncodeServerDescription> servers () const;
+ std::list<EncodeServerDescription> good_servers () const;
+ std::list<EncodeServerDescription> bad_servers () const;
/** Emitted whenever the list of servers changes */
boost::signals2::signal<void ()> ServersListChanged;
/** Thread to listen to the responses from servers */
boost::thread* _listen_thread;
- std::list<EncodeServerDescription> _servers;
+ /** Available servers with the correct link version */
+ std::list<EncodeServerDescription> _good_servers;
+ /** Available servers with an incorrect link version */
+ std::list<EncodeServerDescription> _bad_servers;
+ /** Mutex for _good_servers and _bad_servers */
mutable boost::mutex _servers_mutex;
boost::asio::io_service _listen_io_service;
}
}
- BOOST_FOREACH (EncodeServerDescription i, EncodeServerFinder::instance()->servers ()) {
+ BOOST_FOREACH (EncodeServerDescription i, EncodeServerFinder::instance()->good_servers ()) {
LOG_GENERAL (N_("Adding %1 worker threads for remote %2"), i.threads(), i.host_name ());
for (int j = 0; j < i.threads(); ++j) {
_threads.push_back (new boost::thread (boost::bind (&J2KEncoder::encoder_thread, this, i)));
{
while (true) {
int N = 0;
- list<EncodeServerDescription> servers = EncodeServerFinder::instance()->servers ();
+ list<EncodeServerDescription> servers = EncodeServerFinder::instance()->good_servers ();
/* This is a bit fiddly because we want to list configured servers that are down as well
as all those (configured and found by broadcast) that are up.
cout << std::left << setw(24) << i.host_name() << " UP " << i.threads() << "\n";
++N;
}
+
+ /* And those that have a bad version */
+ BOOST_FOREACH (EncodeServerDescription i, EncodeServerFinder::instance()->good_servers()) {
+ cout << std::left << setw(24) << i.host_name() << " bad version\n";
+ }
}
dcpomatic_sleep (1);
dcpomatic_setup ();
try {
- server = new EncodeServerDescription (server_host, 1);
+ server = new EncodeServerDescription (server_host, 1, SERVER_LINK_VERSION);
film.reset (new Film (film_dir));
film->read_metadata ();
wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
SetSizer (s);
- _list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (400, 200), wxLC_REPORT | wxLC_SINGLE_SEL);
+ _list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (500, 200), wxLC_REPORT | wxLC_SINGLE_SEL);
{
wxListItem ip;
wxListItem ip;
ip.SetId (1);
ip.SetText (_("Threads"));
- ip.SetWidth (100);
+ ip.SetWidth (150);
_list->InsertColumn (1, ip);
}
_list->DeleteAllItems ();
int n = 0;
- BOOST_FOREACH (EncodeServerDescription i, EncodeServerFinder::instance()->servers ()) {
+
+ BOOST_FOREACH (EncodeServerDescription i, EncodeServerFinder::instance()->good_servers()) {
wxListItem list_item;
list_item.SetId (n);
_list->InsertItem (list_item);
++n;
}
+
+ BOOST_FOREACH (EncodeServerDescription i, EncodeServerFinder::instance()->bad_servers()) {
+ wxListItem list_item;
+ list_item.SetId (n);
+ _list->InsertItem (list_item);
+
+ _list->SetItem (n, 0, std_to_wx (i.host_name ()));
+ _list->SetItem (n, 1, _("Incorrect version"));
+
+ ++n;
+ }
}
dcpomatic_sleep (1);
/* "localhost" rather than "127.0.0.1" here fails on docker; go figure */
- EncodeServerDescription description ("127.0.0.1", 1);
+ EncodeServerDescription description ("127.0.0.1", 1, SERVER_LINK_VERSION);
list<thread*> threads;
for (int i = 0; i < 8; ++i) {
dcpomatic_sleep (1);
/* "localhost" rather than "127.0.0.1" here fails on docker; go figure */
- EncodeServerDescription description ("127.0.0.1", 2);
+ EncodeServerDescription description ("127.0.0.1", 2, SERVER_LINK_VERSION);
list<thread*> threads;
for (int i = 0; i < 8; ++i) {
dcpomatic_sleep (1);
/* "localhost" rather than "127.0.0.1" here fails on docker; go figure */
- EncodeServerDescription description ("127.0.0.1", 2);
+ EncodeServerDescription description ("127.0.0.1", 2, SERVER_LINK_VERSION);
list<thread*> threads;
for (int i = 0; i < 8; ++i) {