static void _metisStreamConnection_DestroyOperations(MetisIoOperations **opsPtr) { assertNotNull(opsPtr, "Parameter opsPtr must be non-null double pointer"); assertNotNull(*opsPtr, "Parameter opsPtr must dereference to non-null pointer"); MetisIoOperations *ops = *opsPtr; assertNotNull(metisIoOperations_GetClosure(ops), "ops->context must not be null"); _MetisStreamState *stream = (_MetisStreamState *) metisIoOperations_GetClosure(ops); parcEventQueue_Destroy(&stream->bufferEventVector); metisAddressPair_Release(&stream->addressPair); if (!stream->isClosed) { stream->isClosed = true; metisMessenger_Send(metisForwarder_GetMessenger(stream->metis), metisMissive_Create(MetisMissiveType_ConnectionClosed, stream->id)); } metisMessenger_Send(metisForwarder_GetMessenger(stream->metis), metisMissive_Create(MetisMissiveType_ConnectionDestroyed, stream->id)); if (metisLogger_IsLoggable(stream->logger, MetisLoggerFacility_IO, PARCLogLevel_Info)) { metisLogger_Log(stream->logger, MetisLoggerFacility_IO, PARCLogLevel_Info, __func__, "StreamConnection %p destroyed", (void *) stream); } metisLogger_Release(&stream->logger); parcMemory_Deallocate((void **) &stream); parcMemory_Deallocate((void **) &ops); *opsPtr = NULL; }
static bool _metisConfiguration_AddConnectionEthernet(MetisConfiguration *config, CPIConnectionEthernet *etherConn, CPIAddress *linkAddress, MetisListenerOps *listenerOps) { bool success = false; const char *symbolic = cpiConnectionEthernet_GetSymbolicName(etherConn); if (!metisSymbolicNameTable_Exists(config->symbolicNameTable, symbolic)) { const CPIAddress *remote = cpiConnectionEthernet_GetPeerLinkAddress(etherConn); MetisAddressPair *pair = metisAddressPair_Create(linkAddress, remote); MetisGenericEther *ether = metisEtherListener_GetGenericEtherFromListener(listenerOps); if (ether) { MetisIoOperations *ops = metisEtherConnection_Create(config->metis, ether, pair); if (ops) { MetisConnection *conn = metisConnection_Create(ops); assertNotNull(conn, "Failed to create connection"); metisConnectionTable_Add(metisForwarder_GetConnectionTable(config->metis), conn); metisSymbolicNameTable_Add(config->symbolicNameTable, symbolic, metisConnection_GetConnectionId(conn)); success = true; if (metisLogger_IsLoggable(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Debug)) { char *peerAddressString = cpiAddress_ToString(remote); metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Debug, __func__, "Add connection %s on %s to %s, connid %u", symbolic, cpiConnectionEthernet_GetInterfaceName(etherConn), peerAddressString, metisConnection_GetConnectionId(conn)); parcMemory_Deallocate((void **) &peerAddressString); } } } else { metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Error, __func__, "Could not get MetisGenericEther for listener %p", listenerOps); } metisAddressPair_Release(&pair); } else { if (metisLogger_IsLoggable(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Warning)) { const CPIAddress *remote = cpiConnectionEthernet_GetPeerLinkAddress(etherConn); char *peerAddressString = cpiAddress_ToString(remote); metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Warning, __func__, "Add connection %s on %s to %s failed, symbolic name exists", symbolic, cpiConnectionEthernet_GetInterfaceName(etherConn), peerAddressString); parcMemory_Deallocate((void **) &peerAddressString); } } return success; }