~LDAPService() { this->LockQueue(); for (query_queue::iterator i = this->queries.begin(); i != this->queries.end(); ++i) { LDAPQuery msgid = i->first; LDAPInterface* inter = i->second.second; ldap_abandon_ext(this->con, msgid, NULL, NULL); if (inter) { LDAPResult r; r.error = "LDAP Interface is going away"; inter->OnError(r); } } this->queries.clear(); for (result_queue::iterator i = this->results.begin(); i != this->results.end(); ++i) { LDAPInterface* inter = i->first; LDAPResult* r = i->second; r->error = "LDAP Interface is going away"; if (inter) inter->OnError(*r); } this->results.clear(); this->UnlockQueue(); ldap_unbind_ext(this->con, NULL, NULL); }
void OnNotify() override { for (std::map<Anope::string, LDAPService *>::iterator it = this->LDAPServices.begin(); it != this->LDAPServices.end(); ++it) { LDAPService *s = it->second; LDAPService::query_queue results; s->Lock(); results.swap(s->results); s->Unlock(); for (unsigned int i = 0; i < results.size(); ++i) { LDAPRequest *req = results[i]; LDAPInterface *li = req->inter; LDAPResult *r = req->result; if (li != NULL) { if (!r->getError().empty()) { logger.Log("Error running LDAP query: {0}", r->getError()); li->OnError(*r); } else li->OnResult(*r); } delete req; } } }