/*
* Called when refcount reaches 0 (and safe to destroy).
*
- * The dispatcher must not be locked.
- * The manager must be locked.
+ * The dispatcher must be locked.
+ * The manager must not be locked.
*/
static void
destroy_disp(isc_task_t *task, isc_event_t *event) {
{
dispsocket_t *dispsock;
+ REQUIRE(VALID_QID(qid));
REQUIRE(bucket < qid->qid_nbuckets);
dispsock = ISC_LIST_HEAD(qid->sock_table[bucket]);
{
dns_dispentry_t *res;
+ REQUIRE(VALID_QID(qid));
REQUIRE(bucket < qid->qid_nbuckets);
res = ISC_LIST_HEAD(qid->qid_table[bucket]);
* MUST be unlocked, and not used by anything.
*/
static void
-dispatch_free(dns_dispatch_t **dispp)
-{
+dispatch_free(dns_dispatch_t **dispp) {
dns_dispatch_t *disp;
dns_dispatchmgr_t *mgr;
int i;
*/
LOCK(&qid->lock);
id = (dns_messageid_t)dispatch_random(DISP_ARC4CTX(disp));
- bucket = dns_hash(qid, dest, id, localport);
ok = ISC_FALSE;
for (i = 0; i < 64; i++) {
+ bucket = dns_hash(qid, dest, id, localport);
if (entry_search(qid, dest, id, localport, bucket) == NULL) {
ok = ISC_TRUE;
break;
}
id += qid->qid_increment;
id &= 0x0000ffff;
- bucket = dns_hash(qid, dest, id, localport);
}
UNLOCK(&qid->lock);
res = isc_mempool_get(disp->mgr->rpool);
if (res == NULL) {
- UNLOCK(&disp->lock);
if (dispsocket != NULL)
destroy_dispsocket(disp, &dispsocket);
+ UNLOCK(&disp->lock);
return (ISC_R_NOMEMORY);
}