You've already forked hexagonrpc
mirror of
https://github.com/linux-msm/hexagonrpc.git
synced 2026-02-25 13:13:52 -08:00
fastrpc: rpcd: close remote handle
A request to open a handle should be mirrored with a request to close a handle. Close the remote handle if it was successfully opened.
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
|
||||
#include "aee_error.h"
|
||||
#include "fastrpc.h"
|
||||
#include "fastrpc_adsp_default_listener.h"
|
||||
#include "fastrpc_adsp_listener.h"
|
||||
#include "fastrpc_remotectl.h"
|
||||
|
||||
static int remotectl_open(int fd, char *name, struct fastrpc_context **ctx, void (*err_cb)(const char *err))
|
||||
@@ -59,6 +61,33 @@ static int remotectl_open(int fd, char *name, struct fastrpc_context **ctx, void
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int remotectl_close(struct fastrpc_context *ctx, void (*err_cb)(const char *err))
|
||||
{
|
||||
uint32_t handle;
|
||||
uint32_t dlret;
|
||||
char err[256];
|
||||
int ret;
|
||||
|
||||
ret = fastrpc2(&remotectl_close_def, ctx->fd, REMOTECTL_HANDLE,
|
||||
ctx->handle,
|
||||
&dlret,
|
||||
256, err);
|
||||
|
||||
if (ret == -1) {
|
||||
err_cb(strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (dlret) {
|
||||
err_cb(aee_strerror[dlret]);
|
||||
return dlret;
|
||||
}
|
||||
|
||||
fastrpc_destroy_context(ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void remotectl_err(const char *err)
|
||||
{
|
||||
fprintf(stderr, "Could not remotectl: %s\n", err);
|
||||
@@ -90,10 +119,11 @@ int main()
|
||||
goto err_close_dev;
|
||||
}
|
||||
|
||||
remotectl_open(fd, "adsp_default_listener", &ctx, remotectl_err);
|
||||
printf("{ .fd = %u, .handle = %u, }\n", ctx->fd, ctx->handle);
|
||||
free(ctx);
|
||||
ret = remotectl_open(fd, "adsp_default_listener", &ctx, remotectl_err);
|
||||
if (ret)
|
||||
goto err_close_dev;
|
||||
|
||||
remotectl_close(ctx, remotectl_err);
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user