diff --git a/src/user_interface.cc b/src/user_interface.cc index e3ee6a8..037dd5d 100644 --- a/src/user_interface.cc +++ b/src/user_interface.cc @@ -49,10 +49,19 @@ namespace pEp { _throw_status(status); } - SYNC_EVENT UserInterface::retrieve_next_sync_event(void *management) + SYNC_EVENT UserInterface::retrieve_next_sync_event(void *management, time_t threshold) { - while (adapter.queue().empty()) + time_t started = time(nullptr); + while (adapter.queue().empty()) { + int i = 0; + ++i; + if (i > 10) { + if (time(nullptr) > started + threshold) + break; + i = 0; + } nanosleep((const struct timespec[]){{0, 100000000L}}, NULL); + } return adapter.queue().pop_front(); } diff --git a/src/user_interface.hh b/src/user_interface.hh index 115bff8..a2d52f4 100644 --- a/src/user_interface.hh +++ b/src/user_interface.hh @@ -28,7 +28,7 @@ namespace pEp { protected: static PEP_STATUS _notifyHandshake(void *obj, pEp_identity *me, pEp_identity *partner, sync_handshake_signal signal); - static SYNC_EVENT retrieve_next_sync_event( void *management); + static SYNC_EVENT retrieve_next_sync_event(void *management, time_t threshold); }; class UserInterface_callback : public UserInterface {