crm_initiate_client_tls_handshake(void *session_data, int timeout_ms)
{
    int rc = 0;
    int pollrc = 0;
    time_t start = time(NULL);
    gnutls_session *session = session_data;

    do {
        rc = gnutls_handshake(*session);
        if (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN) {
            pollrc = crm_recv_remote_ready(session, TRUE, 1000);
            if (pollrc < 0) {
                /* poll returned error, there is no hope */
                rc = -1;
            }
        }
    } while (((time(NULL) - start) < (timeout_ms/1000)) &&
            (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN));

    return rc;
}
Weaknesses in this category are related to improper management of system resources.