diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2014-10-04 15:54:45 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2014-10-04 15:54:45 +0200 |
commit | b37c24b94de7e83e7747537508d3e4c86e9e3db5 (patch) | |
tree | 80c67a6721b3f0a7d366b95c0cef604ced97b5f9 /src/ncmpcpp.cpp | |
parent | 7dcf8f4f34325e93f88bcb90235ae4d1d96f2a16 (diff) |
main: limit connection attempts to one per second
Diffstat (limited to 'src/ncmpcpp.cpp')
-rw-r--r-- | src/ncmpcpp.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index e3da219b..db7d7007 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -138,6 +138,7 @@ int main(int argc, char **argv) // local variables bool key_pressed = false; Key input = Key::noOp; + auto connect_attempt = boost::posix_time::from_time_t(0); auto past = boost::posix_time::from_time_t(0); /// enable mouse @@ -156,8 +157,9 @@ int main(int argc, char **argv) { try { - if (!Mpd.Connected()) + if (!Mpd.Connected() && Timer - connect_attempt > boost::posix_time::seconds(1)) { + connect_attempt = Timer; // reset local status info Status::clear(); // clear mpd callback |