From 4b5aff6c604161e890234befc34a43e66b96019c Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Fri, 23 Jun 2017 18:19:42 -0400 Subject: Fix for ICE-8140: the controller occasionally does not find dllTestShutdown --- cpp/test/ios/controller/Bundle/ControllerI.mm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'cpp/test/ios/controller/Bundle/ControllerI.mm') diff --git a/cpp/test/ios/controller/Bundle/ControllerI.mm b/cpp/test/ios/controller/Bundle/ControllerI.mm index 309311b946d..538534a0d4f 100644 --- a/cpp/test/ios/controller/Bundle/ControllerI.mm +++ b/cpp/test/ios/controller/Bundle/ControllerI.mm @@ -193,10 +193,16 @@ MainHelperI::run() return; } - // The following call is necessary to prevent random failures from CFBundleGetFunctionPointerForName - dlsym(_handle, "dllTestShutdown"); + // + // The first CFBundleGetFunction... does not always succeed, so we make up to 3 attempts + // + void* sym = 0; + int attempts = 0; + while((sym = CFBundleGetFunctionPointerForName(_handle, CFSTR("dllTestShutdown"))) == 0 && attempts < 3) + { + attempts++; + } - void* sym = CFBundleGetFunctionPointerForName(_handle, CFSTR("dllTestShutdown")); if(sym == 0) { NSString* err = [NSString stringWithFormat:@"Could not get function pointer dllTestShutdown from bundle %@", @@ -205,6 +211,13 @@ MainHelperI::run() completed(EXIT_FAILURE); return; } + /* + else + { + print([[NSString stringWithFormat:@"*** found dllTestShutdown after %d failed attempt(s)", attempts] UTF8String]); + } + */ + _dllTestShutdown = (SHUTDOWN_ENTRY_POINT)sym; sym = CFBundleGetFunctionPointerForName(_handle, CFSTR("dllMain")); -- cgit v1.2.3