CDB_Connection* CConnection::CloneCDB_Conn() { CHECK_NCBI_DBAPI(m_ds == NULL, "m_ds is not initialized"); CDBDefaultConnParams def_params( GetCDB_Connection()->ServerName(), GetCDB_Connection()->UserName(), GetCDB_Connection()->Password(), GetModeMask(), true ); const CCPPToolkitConnParams params(def_params); def_params.SetHost(GetCDB_Connection()->Host()); def_params.SetPort(GetCDB_Connection()->Port()); def_params.SetDatabaseName(GetDatabase()); def_params.SetParam("do_not_dispatch", "true"); def_params.SetParam("do_not_read_conf", "true"); I_DriverContext* dctx = m_ds->GetDriverContext(); CDB_Connection* tmp_conn = dctx->MakeConnection(params); // If the original connection was known to be in a transaction, // operations using the new one could block on its completion, // possibly yielding a deadlock. In such cases, ensure that the // new connection has a reasonable timeout. (MS SQL offers a // finer-grained LOCK_TIMEOUT setting, but that's not portable, // even to Sybase, which is more prone to such deadlocks in the // first place.) if (GetCDB_Connection()->HasTransaction() && dctx->GetTimeout() == 0) { tmp_conn->SetTimeout(5); } _TRACE("CDB_Connection " << (void*)GetCDB_Connection() << " cloned, new CDB_Connection: " << (void*)tmp_conn); return tmp_conn; }
unsigned int CDBConnectionFactory::CalculateLoginTimeout(const I_DriverContext& ctx) const { unsigned int timeout = 30; unsigned int to = GetLoginTimeout(); if (to != 0) { timeout = to; } else { to = ctx.GetLoginTimeout(); if (to != 0) { timeout = to; } } return timeout; }