Function findConnection [src]

Finds and acquires a connection from the connection pool matching the criteria. This function is threadsafe. If no connection is found, null is returned.

Prototype

pub fn findConnection(pool: *ConnectionPool, criteria: Criteria) ?*Connection

Parameters

pool: *ConnectionPoolcriteria: Criteria

Source

pub fn findConnection(pool: *ConnectionPool, criteria: Criteria) ?*Connection { pool.mutex.lock(); defer pool.mutex.unlock(); var next = pool.free.last; while (next) |node| : (next = node.prev) { if (node.data.protocol != criteria.protocol) continue; if (node.data.port != criteria.port) continue; // Domain names are case-insensitive (RFC 5890, Section 2.3.2.4) if (!std.ascii.eqlIgnoreCase(node.data.host, criteria.host)) continue; pool.acquireUnsafe(node); return &node.data; } return null; }