- bool have_writer = true;
- if (!_nanomsg.send(DISK_WRITER_PING "\n", 2000)) {
- have_writer = false;
- } else {
- auto reply = _nanomsg.receive (2000);
- if (!reply || *reply != DISK_WRITER_PONG) {
- have_writer = false;
+ auto ping = [this](int attempt) {
+ if (_nanomsg.send(DISK_WRITER_PING "\n", 1000)) {
+ auto reply = _nanomsg.receive (1000);
+ if (reply && *reply == DISK_WRITER_PONG) {
+ return true;
+ } else if (reply) {
+ LOG_DISK("Unexpected response %1 to ping received (attempt %2)", *reply, attempt);
+ } else {
+ LOG_DISK("No reply received from ping (attempt %1)", attempt);
+ }
+ } else {
+ LOG_DISK("Could not send ping to writer (attempt %1)", attempt);
+ }
+ dcpomatic_sleep_seconds (1);
+ return false;
+ };
+
+ bool have_writer = false;
+ for (int i = 0; i < 8; ++i) {
+ if (ping(i + 1)) {
+ have_writer = true;
+ break;