return dbversion;
}
-ns_dbversion_t *
-ns_client_findversionid(ns_client_t *client, uintptr_t dbid) {
+static ns_dbversion_t *
+client_findversionid(ns_client_t *client, uintptr_t dbid) {
ISC_LIST_FOREACH(client->query.activeversions, dbversion, link) {
if ((uintptr_t)dbversion->db == dbid) {
return dbversion;
return NULL;
}
+isc_result_t
+ns_client_findversionid(ns_client_t *client, uintptr_t dbid,
+ ns_dbversion_t **dbversionp) {
+ ns_dbversion_t *dbversion = NULL;
+
+ REQUIRE(dbversionp != NULL && *dbversionp == NULL);
+
+ dbversion = client_findversionid(client, dbid);
+ if (dbversion == NULL) {
+ return ISC_R_NOTFOUND;
+ }
+
+ *dbversionp = dbversion;
+ return ISC_R_SUCCESS;
+}
+
ns_dbversion_t *
ns_client_findversion(ns_client_t *client, dns_db_t *db) {
- ISC_LIST_FOREACH(client->query.activeversions, dbversion, link) {
- if (dbversion->db == db) {
- return dbversion;
- }
+ ns_dbversion_t *dbversion = client_findversionid(client, (uintptr_t)db);
+ if (dbversion != NULL) {
+ return dbversion;
}
/*
* This is a new zone for this query. Add it to
* the active list.
*/
- ns_dbversion_t *dbversion = client_getdbversion(client);
+ dbversion = client_getdbversion(client);
dns_db_attach(db, &dbversion->db);
dns_db_currentversion(db, &dbversion->version);
dbversion->acl_checked = false;
* allocated by ns_client_newdbversion().
*/
-ns_dbversion_t *
-ns_client_findversionid(ns_client_t *client, uintptr_t dbid);
+isc_result_t
+ns_client_findversionid(ns_client_t *client, uintptr_t dbid,
+ ns_dbversion_t **dbversionp);
/*%<
* Find the active database version matching database identity 'dbid',
* without allocating a new database version if none is found.
+ *
+ * Requires:
+ *
+ *\li 'dbversionp' points to a NULL ns_dbversion_t *.
+ *
+ * Returns:
+ *
+ *\li #ISC_R_SUCCESS A matching database version was found.
+ *\li #ISC_R_NOTFOUND No matching database version was found.
*/
ISC_REFCOUNT_DECL(ns_clientmgr);
* First, look within the same zone database for authoritative
* additional data.
*/
- dbversion = ns_client_findversionid(client, client->query.authdb_id);
- if (dbversion == NULL) {
- return ISC_R_NOTFOUND;
- }
+ RETERR(ns_client_findversionid(client, client->query.authdb_id,
+ &dbversion));
dns_db_attach(dbversion->db, &db);
version = dbversion->version;