library/src/databases/bpdb/BP-DB.cc
// attempts to search the mariadb connection pool and retrieve a connection by uuid
attempts to search the mariadb connection pool and retrieve a connection by uuid
attempts to search the mariadb connection pool and retrieve a connection by uuid
P_BP_MYSQL_SESSION BP_DBLookupMariadbConnectionByUUID(P_BPDB bpdb, char * uuid)
{
	if(!bpdb)
		return NULL;
	if(!uuid)
	{
		BP_DBAddErrorMsg(bpdb, "BP_DBLookupMariadbConnectionByUUID attempted lookup with null uuid parameter");
		return NULL;
	}
	if(!BP_StringIsReasonablePrintableString(uuid, bpstrlen(uuid), BP_FALSE, BP_FALSE))
	{
		BP_DBAddErrorMsg(bpdb, "BP_DBLookupMariadbConnectionByUUID attempted lookup uuid which was an unreasonable string (contained bad non-ascii chars).");
		return NULL;
	}
	if(!BP_StringIsUUID(uuid))
	{
		BP_DBAddErrorMsg(bpdb, "BP_DBLookupMariadbConnectionByUUID attempted lookup with a uuid which failed our BP_StringIsUUID filter check");
		return NULL;
	}
	BPDB_ENTER_CRITICAL_SECTION;
	char * connection_lookup_path[] =
	{
			"mariadb_connections",
			uuid,
			NULL
	};
	P_BP_HASH_TABLE_KEYED_ENTRY connection_entry = BP_HashRegLookupTableEntryByPath(bpdb->system_hreg, (char **) &connection_lookup_path);
	if(!connection_entry)
	{
		BPDB_LEAVE_CRITICAL_SECTION_AND_RETURN(NULL);
	}
	P_BP_MYSQL_SESSION * session_lookup = (P_BP_MYSQL_SESSION *) connection_entry->data;
	if(!*session_lookup)
	{
		BP_DBAddErrorMsg(bpdb, "BP_DBLookupMariadbConnectionByUUID entry looked up, but mariadb session pointer was NULL after lookup.  This means our connection pool is corrupted.");
		BPDB_LEAVE_CRITICAL_SECTION_AND_RETURN(NULL);
	}
	P_BP_MYSQL_SESSION mysqli = *session_lookup;
	BPDB_LEAVE_CRITICAL_SECTION_AND_RETURN(mysqli);
}
P_BP_MYSQL_SESSION BP_DBLookupMariadbConnectionByUUID ( P_BPDB bpdb , char * uuid ) { if ( ! bpdb ) return NULL ; if ( ! uuid ) { BP_DBAddErrorMsg ( bpdb , " " ) ; return NULL ; } if ( ! BP_StringIsReasonablePrintableString ( uuid , bpstrlen ( uuid ) , BP_FALSE , BP_FALSE ) ) { BP_DBAddErrorMsg ( bpdb , " " ) ; return NULL ; } if ( ! BP_StringIsUUID ( uuid ) ) { BP_DBAddErrorMsg ( bpdb , " " ) ; return NULL ; } BPDB_ENTER_CRITICAL_SECTION ; char * connection_lookup_path [ ] = { " " , uuid , NULL } ; P_BP_HASH_TABLE_KEYED_ENTRY connection_entry = BP_HashRegLookupTableEntryByPath ( bpdb -> system_hreg , ( char * * ) & connection_lookup_path ) ; if ( ! connection_entry ) { BPDB_LEAVE_CRITICAL_SECTION_AND_RETURN ( NULL ) ; } P_BP_MYSQL_SESSION * session_lookup = ( P_BP_MYSQL_SESSION * ) connection_entry -> data ; if ( ! * session_lookup ) { BP_DBAddErrorMsg ( bpdb , " " ) ; BPDB_LEAVE_CRITICAL_SECTION_AND_RETURN ( NULL ) ; } P_BP_MYSQL_SESSION mysqli = * session_lookup ; BPDB_LEAVE_CRITICAL_SECTION_AND_RETURN ( mysqli ) ; }
attempts to search the mariadb connection pool and retrieve a connection by uuid
attempts to search the mariadb connection pool and retrieve a connection by uuid
// run basic checks // enter critical section // set connection lookup path // attempt to lookup the connection entry // note: don't add error here, as this is a lookup routine and null lookups are valid // set session lookup // exit if there is no session to deref into // create mysqli reference // return the reference