MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / Connect

Method Connect

extensions/pgsql/pgsql/PgDriver.cpp:177–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177IDatabase *PgDriver::Connect(const DatabaseInfo *info, bool persistent, char *error, size_t maxlength)
178{
179 std::lock_guard<std::mutex> lock(m_Lock);
180
181 if (persistent)
182 {
183 /* Try to find a matching persistent connection */
184 List<PgDatabase *>::iterator iter;
185 for (iter=m_PermDbs.begin();
186 iter!=m_PermDbs.end();
187 iter++)
188 {
189 PgDatabase *db = (*iter);
190 const DatabaseInfo &other = db->GetInfo();
191 if (CompareField(info->host, other.host)
192 && CompareField(info->user, other.user)
193 && CompareField(info->pass, other.pass)
194 && CompareField(info->database, other.database)
195 && (info->port == other.port))
196 {
197 db->IncReferenceCount();
198 return db;
199 }
200 }
201 }
202
203 PGconn *pgsql = ::Connect(info, error, maxlength);
204 if (!pgsql)
205 {
206 return NULL;
207 }
208
209 PgDatabase *db = new PgDatabase(pgsql, info, persistent);
210
211 if (persistent)
212 {
213 m_PermDbs.push_back(db);
214 }
215
216 return db;
217}
218
219void PgDriver::RemoveFromList(PgDatabase *pdb, bool persistent)
220{

Callers

nothing calls this directly

Calls 6

push_backMethod · 0.80
CompareFieldFunction · 0.70
ConnectFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
IncReferenceCountMethod · 0.45

Tested by

no test coverage detected