]> git.openfabrics.org - ~shefty/ibacm.git/commitdiff
ibacm: Relocate client refcnt
authorSean Hefty <sean.hefty@intel.com>
Thu, 20 Mar 2014 05:14:31 +0000 (22:14 -0700)
committerSean Hefty <sean.hefty@intel.com>
Tue, 8 Apr 2014 22:46:14 +0000 (15:46 -0700)
Adjust when we take a reference on the client connection.
Increment the client reference when we begin processing
the client's request, and release it when the response
has been sent.

The client reference will no longer be associated with the
lifetime of any underlying acm_request structure.  This change
will allow the acm core to control the client reference
count when we move to a provider plug-in model in subsequent
patches.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/acm.c

index a6b4cd20064597adebe459d480c8a51ff2649b11..60032d84f03c05eb793d8503b43c0b03385d71f8 100644 (file)
--- a/src/acm.c
+++ b/src/acm.c
@@ -447,7 +447,6 @@ acm_alloc_req(struct acm_client *client, struct acm_msg *msg)
                return NULL;
        }
 
-       (void) atomic_inc(&client->refcnt);
        req->client = client;
        memcpy(&req->msg, msg, sizeof(req->msg));
        acm_log(2, "client %d, req %p\n", client->index, req);
@@ -458,7 +457,6 @@ static void
 acm_free_req(struct acm_request *req)
 {
        acm_log(2, "%p\n", req);
-       (void) atomic_dec(&req->client->refcnt);
        free(req);
 }
 
@@ -1111,6 +1109,7 @@ acm_client_resolve_resp(struct acm_client *client, struct acm_msg *req_msg,
 
 release:
        lock_release(&client->lock);
+       (void) atomic_dec(&client->refcnt);
        return ret;
 }
 
@@ -1367,6 +1366,7 @@ acm_client_query_resp(struct acm_client *client,
 
 release:
        lock_release(&client->lock);
+       (void) atomic_dec(&client->refcnt);
        return ret;
 }
 
@@ -2338,6 +2338,8 @@ put:
 
 static int acm_svr_resolve(struct acm_client *client, struct acm_msg *msg)
 {
+       (void) atomic_inc(&client->refcnt);
+
        if (msg->resolve_data[0].type == ACM_EP_INFO_PATH) {
                if (msg->resolve_data[0].flags & ACM_FLAGS_QUERY_SA) {
                        return acm_svr_query_path(client, msg);