Browse Source

switch to new_sync_timeout_event()

PYADPT-55
Volker Birk 7 years ago
parent
commit
399618adb5
  1. 10
      src/user_interface.cc

10
src/user_interface.cc

@ -52,16 +52,24 @@ namespace pEp {
SYNC_EVENT UserInterface::retrieve_next_sync_event(void *management, time_t threshold) SYNC_EVENT UserInterface::retrieve_next_sync_event(void *management, time_t threshold)
{ {
time_t started = time(nullptr); time_t started = time(nullptr);
bool timeout = false;
while (adapter.queue().empty()) { while (adapter.queue().empty()) {
int i = 0; int i = 0;
++i; ++i;
if (i > 10) { if (i > 10) {
if (time(nullptr) > started + threshold) if (time(nullptr) > started + threshold) {
timeout = true;
break; break;
}
i = 0; i = 0;
} }
nanosleep((const struct timespec[]){{0, 100000000L}}, NULL); nanosleep((const struct timespec[]){{0, 100000000L}}, NULL);
} }
if (timeout)
return new_sync_timeout_event();
return adapter.queue().pop_front(); return adapter.queue().pop_front();
} }

Loading…
Cancel
Save