Skip to content

Commit b37c24b

Browse files
committed
main: limit connection attempts to one per second
1 parent 7dcf8f4 commit b37c24b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎src/ncmpcpp.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ int main(int argc, char **argv)
138138
// local variables
139139
bool key_pressed = false;
140140
Key input = Key::noOp;
141+
auto connect_attempt = boost::posix_time::from_time_t(0);
141142
auto past = boost::posix_time::from_time_t(0);
142143

143144
/// enable mouse
@@ -156,8 +157,9 @@ int main(int argc, char **argv)
156157
{
157158
try
158159
{
159-
if (!Mpd.Connected())
160+
if (!Mpd.Connected() && Timer - connect_attempt > boost::posix_time::seconds(1))
160161
{
162+
connect_attempt = Timer;
161163
// reset local status info
162164
Status::clear();
163165
// clear mpd callback

0 commit comments

Comments
 (0)