/* Destroys AsyncSocketConnector instance. * Param: * connector - Initialized AsyncSocketConnector instance. */ static void _async_socket_connector_free(AsyncSocketConnector* connector) { if (connector != NULL) { T("ASC %s: Connector is destroying...", _asc_socket_string(connector)); /* Stop all activities. */ if (asyncConnector_stop(connector->connector) == 0) { /* Connection was in progress. We need to destroy I/O descriptor for * that connection. */ D("ASC %s: Stopped async connection in progress.", _asc_socket_string(connector)); loopIo_done(connector->connector_io); } /* Free allocated resources. */ if (connector->looper != NULL) { loopTimer_done(connector->connector_timer); if (connector->owns_looper) { looper_free(connector->looper); } } if (connector->fd >= 0) { socket_close(connector->fd); } T("ASC %s: Connector is destroyed", _asc_socket_string(connector)); sock_address_done(&connector->address); AFREE(connector); } }
void userEventsImpl_destroy(void) { if (_UserEventsImpl.looper != NULL) { // Stop all I/O that may still be going on. loopIo_done(&_UserEventsImpl.io); looper_free(_UserEventsImpl.looper); _UserEventsImpl.looper = NULL; } }
void attachUiProxy_destroy(void) { if (_attachUiProxy.looper != NULL) { // Stop all I/O that may still be going on. loopIo_done(&_attachUiProxy.io); looper_free(_attachUiProxy.looper); _attachUiProxy.looper = NULL; } _attachUiProxy.sock = -1; }
void uiCmdProxy_destroy() { if (_uiCmdProxy.sync_writer != NULL) { syncsocket_close(_uiCmdProxy.sync_writer); syncsocket_free(_uiCmdProxy.sync_writer); } if (_uiCmdProxy.looper != NULL) { loopIo_done(&_uiCmdProxy.io); looper_free(_uiCmdProxy.looper); _uiCmdProxy.looper = NULL; } _uiCmdProxy.sock = -1; }
void coreCmdImpl_destroy() { // Destroy the writer if (_coreCmdImpl.sync_writer != NULL) { syncsocket_close(_coreCmdImpl.sync_writer); syncsocket_free(_coreCmdImpl.sync_writer); } if (_coreCmdImpl.looper != NULL) { // Stop all I/O that may still be going on. loopIo_done(&_coreCmdImpl.io); looper_free(_coreCmdImpl.looper); _coreCmdImpl.looper = NULL; } // Free allocated memory. _free_cmd_param_buf(&_coreCmdImpl); }
/* List emulator core processes running on the given machine. * This routine is called from main() if -list-cores parameter is set in the * command line. * Param: * host Value passed with -list-core parameter. Must be either "localhost", or * an IP address of a machine where core processes must be enumerated. */ static void list_running_cores(const char* host) { Looper* looper; CoreConsole cores[MAX_CORE_PROCS]; SockAddress address; int nn, found; if (sock_address_init_resolve(&address, host, CORE_BASE_PORT, 0) < 0) { derror("Unable to resolve hostname %s: %s", host, errno_str); return; } looper = looper_newGeneric(); for (nn = 0; nn < MAX_CORE_PROCS; nn++) { int port = CORE_BASE_PORT + nn*2; sock_address_set_port(&address, port); coreconsole_init(&cores[nn], &address, looper); } looper_runWithTimeout(looper, CORE_PORT_TIMEOUT_MS*2); found = 0; for (nn = 0; nn < MAX_CORE_PROCS; nn++) { int port = CORE_BASE_PORT + nn*2; if (cores[nn].ok) { if (found == 0) { fprintf(stdout, "Running emulator core processes:\n"); } fprintf(stdout, "Emulator console port %d\n", port); found++; } coreconsole_done(&cores[nn]); } looper_free(looper); if (found == 0) { fprintf(stdout, "There were no running emulator core processes found on %s.\n", host); } }