/** * Opens a connection inside the protocol stack: it calls open() on each component. * * Returns 0 on success, -1 on error * * Example: * @code * <#example#> * @endcode */ int rtaProtocolStack_Open(RtaProtocolStack *stack, RtaConnection *connection) { assertNotNull(stack, "called with null stack\n"); if (DEBUG_OUTPUT) { printf("%9" PRIu64 " %s stack_id %d opening conn %p api_fd %d\n", rtaFramework_GetTicks(rtaProtocolStack_GetFramework(stack)), __func__, stack->stack_id, (void *) connection, rtaConnection_GetApiFd(connection)); } // call all the opens, except the api // need to disable events during creation to avoid calling the event notifier // of a component before the component sees the "open" call for this connection stack->stateChangeEventsEnabled = false; for (int i = 0; i < stack->component_count; i++) { RtaComponents comp = stack->components[i]; if (stack->component_ops[comp].open != NULL && stack->component_ops[comp].open(connection) != 0) { fprintf(stderr, "%s component %d failed open\n", __func__, i); abort(); return -1; } } stack->stateChangeEventsEnabled = true; return 0; }
LONGBOW_TEST_CASE(Global, rtaApiConnection_Create_Checks) { TestData *data = longBowTestCase_GetClipBoardData(testCase); RtaApiConnection *apiConnection = rtaApiConnection_Create(data->connection); assertTrue(apiConnection->api_fd == rtaConnection_GetApiFd(data->connection), "Wrong api fd, got %d expected %d", apiConnection->api_fd, rtaConnection_GetApiFd(data->connection)); assertTrue(apiConnection->transport_fd == rtaConnection_GetTransportFd(data->connection), "Wrong api fd, got %d expected %d", apiConnection->transport_fd, rtaConnection_GetTransportFd(data->connection)); assertTrue(apiConnection->connection == data->connection, "Wrong connection, got %p expected %p", (void *) apiConnection->connection, (void *) data->connection); rtaApiConnection_Destroy(&apiConnection); }