Skip to content

Commit 249b0f7

Browse files
author
Ekansh Gupta
committed
Handle session close properly
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 <quic_ekangupt@quicinc.com>
1 parent 3fbe5e3 commit 249b0f7

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

inc/fastrpc_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int fastrpc_session_open(int domain, int *dev);
167167
/**
168168
* @brief closes the remote session/file descriptor of the fastrpc device node
169169
*/
170-
int fastrpc_session_close(int domain);
170+
void fastrpc_session_close(int domain, int dev);
171171
/**
172172
* @brief increments the reference count of the domain
173173
* used to identify whether there are any active remote calls for a specific domain

src/fastrpc_apps_user.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,18 @@ int fastrpc_session_open(int domain, int *dev) {
363363
return AEE_ECONNREFUSED;
364364
}
365365

366-
int fastrpc_session_close(int domain) {
367-
int dev = hlist[domain].dev;
368-
369-
if (dev >= 0)
366+
void fastrpc_session_close(int domain, int dev) {
367+
if (!hlist)
368+
return;
369+
if ((hlist[domain].dev == INVALID_DEVICE) &&
370+
(dev != INVALID_DEVICE)) {
370371
close(dev);
371-
return 0;
372+
} else if ((hlist[domain].dev != INVALID_DEVICE) &&
373+
(dev == INVALID_DEVICE)) {
374+
close(hlist[domain].dev);
375+
hlist[domain].dev = INVALID_DEVICE;
376+
}
377+
return;
372378
}
373379

374380
int fastrpc_session_get(int domain) {

src/fastrpc_cap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ int fastrpc_get_cap(uint32_t domain, uint32_t attributeID, uint32_t *capability)
128128

129129
bail:
130130
if(dev != -1)
131-
fastrpc_session_close(dom);
131+
fastrpc_session_close(dom, dev);
132132
if (nErr) {
133133
FARF(ERROR, "Warning 0x%x: %s failed to get attribute %u for domain %u (errno %s)", nErr, __func__, attributeID, domain, strerror(errno));
134134
}

src/fastrpc_context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static int fastrpc_context_deinit(fastrpc_context *ctx) {
134134
if (!ctx->devs[i])
135135
continue;
136136

137-
fastrpc_session_close(domain);
137+
fastrpc_session_close(domain, INVALID_DEVICE);
138138
}
139139
free(ctx->devs);
140140

0 commit comments

Comments
 (0)