PengZheng commented on code in PR #476: URL: https://github.com/apache/celix/pull/476#discussion_r1117892465
########## libs/framework/src/celix_launcher.c: ########## @@ -62,107 +76,93 @@ int celixLauncher_launchAndWaitForShutdown(int argc, char *argv[], celix_propert opt = argv[1]; } - char *config_file = NULL; + char* configFile = NULL; bool showProps = false; bool showEmbeddedBundles = false; + bool createCache = false; for (int i = 1; i < argc; ++i) { opt = argv[i]; // Check whether the user wants some help... if (strncmp("-?", opt, strlen("-?")) == 0 || strncmp("-h", opt, strlen("-h")) == 0 || strncmp("--help", opt, strlen("--help")) == 0) { - show_usage(argv[0]); - celix_properties_destroy(packedConfig); + celixLauncher_printUsage(argv[0]); + celix_properties_destroy(embeddedConfig); return 0; } else if (strncmp("-p", opt, strlen("-p")) == 0 || strncmp("--props", opt, strlen("--props")) == 0) { showProps = true; + } else if (strncmp("-c", opt, strlen("-c")) == 0 || strncmp("--create-bundle-cache", opt, strlen("--create-bundle-cache")) == 0) { + createCache = true; } else if (strncmp("--embedded_bundles", opt, strlen("--embedded_bundles")) == 0) { showEmbeddedBundles = true; } else { - config_file = opt; + configFile = opt; } } - if (config_file == NULL) { - config_file = DEFAULT_CONFIG_FILE; + if (configFile == NULL) { + configFile = DEFAULT_CONFIG_FILE; } - if (packedConfig == NULL) { - packedConfig = celix_properties_create(); + if (embeddedConfig == NULL) { + embeddedConfig = celix_properties_create(); } if (showProps) { - show_properties(packedConfig, config_file); - celix_properties_destroy(packedConfig); + celixLauncher_printProperties(embeddedConfig, configFile); + celix_properties_destroy(embeddedConfig); return 0; } + if (createCache) { + return celixLauncher_createBundleCache(embeddedConfig, configFile); + } + if (showEmbeddedBundles) { - printEmbeddedBundles(); - celix_properties_destroy(packedConfig); + celixLauncher_printEmbeddedBundles(); + celix_properties_destroy(embeddedConfig); return 0; } struct sigaction sigact; memset(&sigact, 0, sizeof(sigact)); - sigact.sa_handler = shutdown_framework; + sigact.sa_handler = celixLauncher_shutdownFramework; Review Comment: Only async-signal-safe functions can be called in signal handler. `celixLauncher_shutdownFramework` calls `celixThreadMutex_lock` and other non-async-signal-safe functions like `fprintf`, and thus is not async-signal-safe. To fix this we have to design a mechanism to communicate with the event loop from signal handler, which is not trivial. Considering `write` is async-signal-safe, pipe/event fd may be used to pass event to our event loop. This is really a corner-case, and should be fixed in another PR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org