Skip to content

Commit

Permalink
connmgr: more fixups..
Browse files Browse the repository at this point in the history
Change-Id: I892bcfac5e8f22e0579573822f717412fd16886f
  • Loading branch information
mnunberg committed Feb 1, 2014
1 parent fa723be commit 7674642
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/connmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ static void invoke_request(connmgr_request *req)
connmgr_cinfo *info = (connmgr_cinfo *)req->conn->poolinfo;
lcb_assert(info->state == CS_IDLE);
info->state = CS_LEASED;
req->state = RS_ASSIGNED;
lcb_timer_disarm(info->idle_timer);
}

Expand Down Expand Up @@ -249,7 +250,7 @@ static void async_invoke_request(lcb_timer_t tm, lcb_t instance, const void *coo
void connmgr_get(connmgr_t *pool, connmgr_request *req, lcb_uint32_t timeout)
{
connmgr_hostent *he;
lcb_list_t *cur, *next;
lcb_list_t *cur;

if (req->state != RS_UNINIT) {
lcb_log(LOGARGS(pool, INFO),
Expand All @@ -276,27 +277,21 @@ void connmgr_get(connmgr_t *pool, connmgr_request *req, lcb_uint32_t timeout)
genhash_store(pool->ht, he->key, strlen(he->key), he, 0);
}


req->conn = NULL;
req->he = he;
cur = lcb_clist_pop(&he->ll_idle);

LCB_LIST_SAFE_FOR(cur, next, (lcb_list_t *)&he->ll_idle) {
if (cur) {
connmgr_cinfo *info = LCB_LIST_ITEM(cur, connmgr_cinfo, llnode);
lcb_error_t err;

lcb_clist_delete(&he->ll_idle, &info->llnode);
lcb_timer_disarm(info->idle_timer);

req->conn = &info->connection;
info->state = CS_LEASED;
he->n_leased++;
break;
}

if (req->conn) {
lcb_error_t err;
req->state = RS_ASSIGNED;
req->timer = lcb_async_create(pool->io, req, async_invoke_request, &err);
lcb_log(LOGARGS(pool, INFO), "Pairing connection with request..");

info->state = CS_LEASED;
he->n_leased++;

} else {
req->state = RS_PENDING;
Expand Down

0 comments on commit 7674642

Please sign in to comment.