diff --git a/channels/chan_brcm.c b/channels/chan_brcm.c index 71841732fc4222d0a72cf2456f593855362c9602..131936aca57a99da077e94d8dea1db2801faf2f0 100644 --- a/channels/chan_brcm.c +++ b/channels/chan_brcm.c @@ -3320,6 +3320,7 @@ static void ubus_stream_handler(pe_stream_t *stream __attribute__((unused)), pe_ static int ubus_init(void) { pe_stream_t *ubus_stream; + int try = 0; base = pe_base_new(); if (base < 0) @@ -3347,10 +3348,16 @@ static int ubus_init(void) { } /* Lookup path to Endptmngr AFTER registration of ubus object - * event handler above. It's no error if lookup fails. */ - if(ubus_lookup_id(ctx, endpt_ubus_path, - (uint32_t*) &endpt_id) != UBUS_STATUS_OK) { - endpt_id = 0; + * event handler above. When lookup fails endptmngr hangs causing + * chan_brcm.so module is not loaded and asterisk is not fully working + * so keep trying for 20s */ + for (try = 0; try < 20 && endpt_id == 0; try++) { + if(ubus_lookup_id(ctx, endpt_ubus_path, + (uint32_t*) &endpt_id) != UBUS_STATUS_OK) { + endpt_id = 0; + ast_log(LOG_DEBUG, "Waiting for endptmngr...\n"); + sleep(1); + } } if (ubus_add_object(ctx, &asterisk_obj) != UBUS_STATUS_OK) {