/** * Stop watching the list of watched directories */ void sxe_dirwatch_stop(void) { SXEE60("sxe_stat_stop()"); ev_io_stop(sxe_private_main_loop, &sxe_dirwatch_watcher); SXER60("return"); }
SXE_RETURN sxe_spawn_init(void) { SXEE60("sxe_spawn_init()"); SXER60("return SXE_RETURN_OK"); return SXE_RETURN_OK; }
static void sxe_load_connect_ramp_tcp(void) { unsigned int i; SXE_RETURN result; unsigned int connection_id; SXEE60("tcp_connect_ramp()"); for (i = 0; i < sxe_load_connect_ramp; i++) { connection_id = sxe_pool_set_oldest_element_state(sxe_load_connection_pool, SXE_LOAD_CONNECTION_STATE_FREE, SXE_LOAD_CONNECTION_STATE_AWAITING_CONNECT); if (connection_id == SXE_POOL_NO_INDEX) { SXEL60("All connections established"); goto SXE_EARLY_OUT; } /* loop until we can bind and connect successfully (port/ip chosen might already be inuse by the system) */ do { sxe_load_connection_pool[connection_id].connection = sxe_new_tcp(NULL, sxe_load_client_ip_as_text[sxe_load_client_ip_index], sxe_load_next_port, sxe_load_event_connect_tcp, sxe_load_event_read_client_tcp, sxe_load_event_close_tcp); result = sxe_connect(sxe_load_connection_pool[connection_id].connection, sxe_load_server_ip, sxe_load_server_port); sxe_load_client_ip_index++; if (sxe_load_client_ip_index == sxe_load_client_ip_count) { sxe_load_client_ip_index = 0; sxe_load_next_port--; if (sxe_load_next_port <= 1024) { sxe_load_next_port = 65535; } } if (result != SXE_RETURN_OK) { sxe_close(sxe_load_connection_pool[connection_id].connection); } } while (result != SXE_RETURN_OK); SXEL60("Starting new tcp connection"); /* save the pool index in the SXE extra data */ SXE_USER_DATA_AS_INT(sxe_load_connection_pool[connection_id].connection) = connection_id; sxe_load_connection_pool[connection_id].connecting_time = sxe_time_get(); sxe_load_connection_pool[connection_id].queries_completed = 0; } SXE_EARLY_OR_ERROR_OUT: SXER60("return"); }
/** * Initialize the dirwatch package * * @exceptions Aborts if already initialized or on failure to initialize inotify */ void sxe_dirwatch_init(void) { SXEE60("()"); if (sxe_dirwatch_inotify_fd != -1) { SXEL60("sxe_dirwatch_init: Already initialized"); goto SXE_EARLY_OUT; } SXEA11((sxe_dirwatch_inotify_fd = inotify_init()) != -1, "sxe_dirwatch_init: inotify_init() failed with %s", strerror(errno)); SXEL61("inotify_init() returned fd: %d", sxe_dirwatch_inotify_fd); SXE_LIST_CONSTRUCT(&sxe_dirwatch_list, 0, SXE_DIRWATCH, node); ev_io_init(&sxe_dirwatch_watcher, sxe_dirwatch_event, sxe_dirwatch_inotify_fd, EV_READ); SXE_EARLY_OUT: SXER60("return"); }
int main(void) { struct object self; struct object * this = &self; plan_tests(47); /* Test sxe_return_to_string() */ is_eq(sxe_return_to_string(SXE_RETURN_OK), "OK" , "sxe_return_to_string(SXE_RETURN_OK) eq \"OK\""); is_eq(sxe_return_to_string(SXE_RETURN_ERROR_INTERNAL), "ERROR_INTERNAL", "sxe_return_to_string(SXE_RETURN_ERROR_INTERNAL) eq \"ERROR_INTERNAL\""); is( sxe_return_to_string(~0U), NULL, "sxe_return_to_string(~0U) == NULL"); TEST_CASE_RETURN_TO_STRING(EXPIRED_VALUE); TEST_CASE_RETURN_TO_STRING(NO_UNUSED_ELEMENTS); TEST_CASE_RETURN_TO_STRING(IN_PROGRESS); TEST_CASE_RETURN_TO_STRING(UNCATEGORIZED); TEST_CASE_RETURN_TO_STRING(END_OF_FILE); TEST_CASE_RETURN_TO_STRING(WARN_ALREADY_INITIALIZED); TEST_CASE_RETURN_TO_STRING(WARN_WOULD_BLOCK); TEST_CASE_RETURN_TO_STRING(WARN_ALREADY_CLOSED); TEST_CASE_RETURN_TO_STRING(ERROR_NOT_INITIALIZED); TEST_CASE_RETURN_TO_STRING(ERROR_ALLOC); TEST_CASE_RETURN_TO_STRING(ERROR_NO_CONNECTION); TEST_CASE_RETURN_TO_STRING(ERROR_ALREADY_CONNECTED); TEST_CASE_RETURN_TO_STRING(ERROR_INVALID_URI); TEST_CASE_RETURN_TO_STRING(ERROR_BAD_MESSAGE); TEST_CASE_RETURN_TO_STRING(ERROR_ADDRESS_IN_USE); TEST_CASE_RETURN_TO_STRING(ERROR_INTERRUPTED); TEST_CASE_RETURN_TO_STRING(ERROR_COMMAND_NOT_RUN); TEST_CASE_RETURN_TO_STRING(ERROR_LOCK_NOT_TAKEN); TEST_CASE_RETURN_TO_STRING(ERROR_INCORRECT_STATE); TEST_CASE_RETURN_TO_STRING(ERROR_TIMED_OUT); TEST_CASE_RETURN_TO_STRING(ERROR_WRITE_FAILED); TEST_CASE_RETURN_TO_STRING(INVALID_VALUE); /* Just for coverage */ ok(signal(SIGABRT, test_abort_handler) != SIG_ERR, "Caught abort signal"); sxe_log_hook_line_out(NULL); /* for coverage */ sxe_log_hook_line_out(log_line); PUTENV("SXE_LOG_LEVEL=6"); /* Trigger processing of the level in the first call to the log */ SXEE60(entering); PUTENV("SXE_LOG_LEVEL=1"); /* This should be ignored. If it is not, the tests will fail */ this->id = 99; SXEL60I(logging); SXEA60(1, "Asserting true"); SXED60(dumpdata, 4); SXER60(exiting); SXEL60(verylong); SXEE61("really long entry message: %s", verylong); SXEL60(escape); SXEL60(hextrunc); SXED60(dumpdata, 0); /* Edge case */ SXEA80(1, "We should not get this, because level 8 is too low!"); is(sxe_log_decrease_level(SXE_LOG_LEVEL_ERROR), SXE_LOG_LEVEL_TRACE, "Level decreased to ERROR (2) from TRACE (6)"); is(sxe_log_set_level( SXE_LOG_LEVEL_INFORMATION), SXE_LOG_LEVEL_ERROR, "Level set to INFO, was ERROR"); is(sxe_log_decrease_level(SXE_LOG_LEVEL_TRACE), SXE_LOG_LEVEL_INFORMATION, "Level was INFO, TRACE is not a decrease"); #if defined(_WIN32) && defined(LOCAL_SXE_DEBUG) skip(3, "Can't test aborts in a Windows debug build, due to pop up Window stopping the build"); #else SXEA60(this != &self, "This is not self"); /* Abort - must be the last thing we do*/ fail("Did not catch an abort signal"); #endif } /* Oog! Close the brace opened in the SXEE61 macro above */