library/src/databases/bpdb/BP-DB.cc
// Attempts to close all connections in the mariadb connection pool.
Attempts to close all connections in the mariadb connection pool.
Attempts to close all connections in the mariadb connection pool .
BP_ERROR_T BP_DBCloseMariaDBConnectionPool(P_BPDB bpdb)
{
	if(!bpdb)
		return ERR_FAILURE;
	P_BP_HTKE mariadb_conn_table = BP_HashRegLookupTableByPathQuery(bpdb->system_hreg, "/mariadb_connections");
	if(!mariadb_conn_table)
	{
		BP_DBAddErrorMsg(bpdb, "Failed to lookup the mariadb_connections table within the system_hreg.");
		return ERR_FAILURE;
	}
	BP_BOOL one_or_more_connections_failed_to_close = BP_FALSE;
	BP_HASH_ITER_OPEN((P_BP_HTKE) mariadb_conn_table->data, mariadb_conn_iter_entry)
	{
		P_BP_MYSQL_SESSION * tmp_session_ptr = (P_BP_MYSQL_SESSION *) mariadb_conn_iter_entry->data;
		if(!tmp_session_ptr)
			continue;
		if(!tmp_session_ptr[0])
			continue;
		if(!BP_MySQLClose(tmp_session_ptr[0]))
		{
			BP_DBAddErrorMsg(bpdb, "Connection failed to close with BP_MySQLClose() within BP_DBCloseMariaDBConnectionPool().  This should not occur under normal circumstances.");
			one_or_more_connections_failed_to_close = BP_TRUE;
		}
	}
	BP_HASH_ITER_CLOSE;
	if(one_or_more_connections_failed_to_close)
		return ERR_FAILURE;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DBCloseMariaDBConnectionPool ( P_BPDB bpdb ) { if ( ! bpdb ) return ERR_FAILURE ; P_BP_HTKE mariadb_conn_table = BP_HashRegLookupTableByPathQuery ( bpdb -> system_hreg , " " ) ; if ( ! mariadb_conn_table ) { BP_DBAddErrorMsg ( bpdb , " " ) ; return ERR_FAILURE ; } BP_BOOL one_or_more_connections_failed_to_close = BP_FALSE ; BP_HASH_ITER_OPEN ( ( P_BP_HTKE ) mariadb_conn_table -> data , mariadb_conn_iter_entry ) { P_BP_MYSQL_SESSION * tmp_session_ptr = ( P_BP_MYSQL_SESSION * ) mariadb_conn_iter_entry -> data ; if ( ! tmp_session_ptr ) continue ; if ( ! tmp_session_ptr [ 0 ] ) continue ; if ( ! BP_MySQLClose ( tmp_session_ptr [ 0 ] ) ) { BP_DBAddErrorMsg ( bpdb , " " ) ; one_or_more_connections_failed_to_close = BP_TRUE ; } } BP_HASH_ITER_CLOSE ; if ( one_or_more_connections_failed_to_close ) return ERR_FAILURE ; return ERR_SUCCESS ; }
Attempts to close all connections in the mariadb connection pool.
Attempts to close all connections in the mariadb connection pool .
// ensure we have a bpdb connection // attempt to lookup the connections table via path query // close/fail indicator // iterate through connections in the table and close them one by one // set pointer from local data // ensure we have a session pointer // attempt to close the connection // if one or more failed to close, return indicating failure // return indicating success