X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-session.c;h=8b566838c758f901bc25a03a431d66b6c997e62b;hb=4d5ce1b0b3b41b8fb53126a0c67534db7d010a75;hp=536cdbccd46d6faa1e2c31cbc2035dc816122c12;hpb=b596b217c9b82d6be2b1d5486cdced31831aebc3;p=src%2Fapp-framework-binder.git diff --git a/src/afb-session.c b/src/afb-session.c index 536cdbcc..8b566838 100644 --- a/src/afb-session.c +++ b/src/afb-session.c @@ -120,7 +120,7 @@ static void free_data (struct afb_session *session) void afb_session_init (int max_session_count, int timeout, const char *initok) { // let's create as store as hashtable does not have any - sessions.store = calloc (1 + (unsigned)max_session_count, sizeof(struct afb_session)); + sessions.store = calloc (1 + (unsigned)max_session_count, sizeof *sessions.store); pthread_mutex_init(&sessions.mutex, NULL); sessions.max = max_session_count; sessions.timeout = timeout; @@ -135,6 +135,11 @@ void afb_session_init (int max_session_count, int timeout, const char *initok) } } +const char *afb_session_initial_token() +{ + return sessions.initok; +} + static struct afb_session *search (const char* uuid) { int idx; @@ -309,6 +314,8 @@ struct afb_session *afb_session_get (const char *uuid, int *created) /* search for an existing one not too old */ if (uuid != NULL) { session = search(uuid); + if (!created) + return session; if (session != NULL) { *created = 0; session->access = now; @@ -317,7 +324,9 @@ struct afb_session *afb_session_get (const char *uuid, int *created) } } - *created = 1; + if (created) + *created = 1; + return make_session(uuid, sessions.timeout, now); }