Skip to content

Commit

Permalink
fastrpc_notif: convert notif array to hash-table
Browse files Browse the repository at this point in the history
Convert notif array to hash-table to handle dynamic number of domains.

Change-Id: Id81df5da4b7b8d7d9be09a44e37eb21265c1cd29
Signed-off-by: Thyagarajan Venkatanarayanan <quic_venkatan@quicinc.com>
  • Loading branch information
Thyagarajan Venkatanarayanan authored and thyagarajanqc committed Nov 6, 2024
1 parent 99eae84 commit c3a33cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
23 changes: 19 additions & 4 deletions src/fastrpc_notif.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
#include "fastrpc_notif.h"
#include "platform_libs.h"
#include "verify.h"
#include "fastrpc_hash_table.h"

struct notif_config {
pthread_t thread;
int init_done;
int deinit_started;
ADD_DOMAIN_HASH();
};

// Fastrpc client notification request node to be queued to <notif_list>
Expand All @@ -47,15 +49,16 @@ struct other_handle_list { // For non-domain and reverse handl

/* Mutex to protect notif_list */
static pthread_mutex_t update_notif_list_mut;
static struct notif_config lnotifinfo[NUM_DOMAINS_EXTEND];
/* List of all clients who registered for process status notification */
static struct other_handle_list notif_list;

void fastrpc_cleanup_notif_list();

DECLARE_HASH_TABLE(fastrpc_notif, struct notif_config);

static void *notif_fastrpc_thread(void *arg) {
struct notif_config *me = (struct notif_config *)arg;
int nErr = AEE_SUCCESS, domain = (int)(me - &lnotifinfo[0]);
int nErr = AEE_SUCCESS, domain = me->domain;

do {
nErr = get_remote_notif_response(domain);
Expand All @@ -81,19 +84,27 @@ void notif_thread_exit_handler(int sig) {
}

void fastrpc_notif_init() {
HASH_TABLE_INIT(struct notif_config);
QList_Ctor(&notif_list.ql);
pthread_mutex_init(&update_notif_list_mut, 0);
}

void fastrpc_notif_deinit() {
HASH_TABLE_CLEANUP(struct notif_config);
fastrpc_cleanup_notif_list();
pthread_mutex_destroy(&update_notif_list_mut);
}

void fastrpc_notif_domain_deinit(int domain) {
struct notif_config *me = &lnotifinfo[domain];
struct notif_config *me = NULL;
int err = 0;

GET_HASH_NODE(struct notif_config, domain, me);
if (!me) {
FARF(ERROR, "Error: %s: unable to find hash-node for domain %d",
__func__, domain);
return;
}
if (me->thread) {
FARF(ALWAYS, "%s: Waiting for FastRPC notification worker thread to join",
__func__);
Expand All @@ -111,10 +122,14 @@ void fastrpc_notif_domain_deinit(int domain) {
}

int fastrpc_notif_domain_init(int domain) {
struct notif_config *me = &lnotifinfo[domain];
struct notif_config *me = NULL;
int nErr = AEE_SUCCESS;
struct sigaction siga;

GET_HASH_NODE(struct notif_config, domain, me);
if (!me) {
ALLOC_AND_ADD_NEW_NODE_TO_TABLE(struct notif_config, domain, me);
}
if (me->init_done) {
goto bail;
}
Expand Down
5 changes: 4 additions & 1 deletion src/listener_android.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,10 @@ int listener_android_domain_init(int domain, int update_requested,
struct listener *me = NULL;
int nErr = AEE_SUCCESS;

ALLOC_AND_ADD_NEW_NODE_TO_TABLE(struct listener, domain, me);
GET_HASH_NODE(struct listener, domain, me);
if (!me) {
ALLOC_AND_ADD_NEW_NODE_TO_TABLE(struct listener, domain, me);
}
me->eventfd = -1;
VERIFYC(-1 != (me->eventfd = eventfd(0, 0)), AEE_EBADPARM);
FARF(RUNTIME_RPC_HIGH, "Opened Listener event_fd %d for domain %d\n",
Expand Down

0 comments on commit c3a33cf

Please sign in to comment.