Skip to content

Commit

Permalink
Handle session close properly
Browse files Browse the repository at this point in the history
Session close call is used by capability and context management
functions. The handling should be in such a way that capability
request should not close the device node if the PD is established.
Handle session close correctly.

Signed-off-by: Ekansh Gupta <[email protected]>
  • Loading branch information
quic-ekangupt committed Nov 22, 2024
1 parent 6d4c1d5 commit 3630375
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion inc/fastrpc_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/fastrpc_apps_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/fastrpc_cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/fastrpc_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3630375

Please sign in to comment.