diff --git a/inc/fastrpc_common.h b/inc/fastrpc_common.h index 2c5e9b3..6a21549 100644 --- a/inc/fastrpc_common.h +++ b/inc/fastrpc_common.h @@ -167,7 +167,7 @@ int fastrpc_session_open(int domain, int *dev); /** * @brief closes the remote session/file descriptor of the fastrpc device node */ -int fastrpc_session_close(int domain); +int fastrpc_session_close(int domain, int dev); /** * @brief increments the reference count of the domain * used to identify whether there are any active remote calls for a specific domain diff --git a/src/fastrpc_apps_user.c b/src/fastrpc_apps_user.c index 7474d66..4c8b684 100644 --- a/src/fastrpc_apps_user.c +++ b/src/fastrpc_apps_user.c @@ -362,11 +362,13 @@ int fastrpc_session_open(int domain, int *dev) { return AEE_ECONNREFUSED; } -int fastrpc_session_close(int domain) { - int dev = hlist[domain].dev; - - if (dev >= 0) +int fastrpc_session_close(int domain, int dev) { + if (!hlist) + return AEE_ENOTINITIALIZED; + if (hlist[domain].dev == -1) close(dev); + if (dev == -1 && hlist[domain].dev > 0) + close(hlist[domain].dev); return 0; } diff --git a/src/fastrpc_cap.c b/src/fastrpc_cap.c index da80873..a31eb8b 100644 --- a/src/fastrpc_cap.c +++ b/src/fastrpc_cap.c @@ -128,7 +128,7 @@ int fastrpc_get_cap(uint32_t domain, uint32_t attributeID, uint32_t *capability) bail: if(dev != -1) - fastrpc_session_close(dom); + fastrpc_session_close(dom, dev); if (nErr) { FARF(ERROR, "Warning 0x%x: %s failed to get attribute %u for domain %u (errno %s)", nErr, __func__, attributeID, domain, strerror(errno)); } diff --git a/src/fastrpc_context.c b/src/fastrpc_context.c index e37fb02..2276d42 100644 --- a/src/fastrpc_context.c +++ b/src/fastrpc_context.c @@ -134,7 +134,7 @@ static int fastrpc_context_deinit(fastrpc_context *ctx) { if (!ctx->devs[i]) continue; - fastrpc_session_close(domain); + fastrpc_session_close(domain, -1); } free(ctx->devs);