static GList *p_cache_list = NULL;
static guint event_id;
+static guint session_reinit_timer;
guint nap_connected_device_count = 0;
static guint hid_connected_device_count = 0;
static GList *p_adv_ind_list = NULL;
return BLUETOOTH_ERROR_NONE;
}
+gboolean __bt_reinit_obexd_receiver(gpointer user_data)
+{
+ static int retry_cnt = 0;
+ int result = BLUETOOTH_ERROR_NONE;
+
+ BT_DBG("+");
+
+ result = __bt_init_obexd_receiver();
+ if (result != BLUETOOTH_ERROR_NONE) {
+ /* 20 ms * 50 = 10 seconds. During 10 seconds fail to initialize,
+ then it is not the timing issue. Just can't use the session bus connection */
+ if (retry_cnt > 100) {
+ BT_ERR("Fail to init obexd receiver by 50 times.");
+ retry_cnt = 0;
+ session_reinit_timer = 0;
+ return FALSE;
+ }
+ retry_cnt++;
+ BT_DBG("Retry to initialize the obexd receiver");
+ return TRUE;
+ }
+
+ retry_cnt = 0;
+ session_reinit_timer = 0;
+
+ BT_DBG("-");
+
+ return FALSE;
+}
+
/* To receive the event from bluez */
int _bt_init_service_event_receiver(void)
{
retv_if(result != BLUETOOTH_ERROR_NONE, result);
result = __bt_init_obexd_receiver();
- if (result != BLUETOOTH_ERROR_NONE)
+ if (result != BLUETOOTH_ERROR_NONE) {
BT_ERR("Fail to init obexd receiver");
+ /* Try to re-initialize obexd receiver in the timer */
+ if (session_reinit_timer > 0)
+ g_source_remove(session_reinit_timer);
+
+ session_reinit_timer = g_timeout_add(BT_SESSION_BUS_GET_TIMEOUT,
+ (GSourceFunc)__bt_reinit_obexd_receiver, NULL);
+ }
+
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;