diff --git a/inc/fastrpc_common.h b/inc/fastrpc_common.h index d9c323f..92f56d5 100644 --- a/inc/fastrpc_common.h +++ b/inc/fastrpc_common.h @@ -146,7 +146,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 dev); +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 2e76533..18920f5 100644 --- a/src/fastrpc_apps_user.c +++ b/src/fastrpc_apps_user.c @@ -342,6 +342,12 @@ void set_thread_context(int domain) { int fastrpc_session_open(int domain, int *dev) { int device = -1; + + if(IS_SESSION_OPEN_ALREADY(domain)) { + *dev = hlist[domain].dev; + return 0; + } + device = open_device_node(domain); if (device >= 0) { *dev = device; @@ -350,8 +356,9 @@ int fastrpc_session_open(int domain, int *dev) { return AEE_EUNKNOWN; } -int fastrpc_session_close(int dev) { - close(dev); +int fastrpc_session_close(int domain, int dev) { + if(hlist[domain].dev == -1) + close(dev); return 0; } diff --git a/src/fastrpc_cap.c b/src/fastrpc_cap.c index 4139da5..3733a21 100644 --- a/src/fastrpc_cap.c +++ b/src/fastrpc_cap.c @@ -125,7 +125,7 @@ int fastrpc_get_cap(uint32_t domain, uint32_t attributeID, uint32_t *capability) bail: if(dev != -1) - fastrpc_session_close(dev); + 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)); }