Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
afb-session: improve naming
[src/app-framework-binder.git]
/
src
/
afb-session.c
diff --git
a/src/afb-session.c
b/src/afb-session.c
index
c941eef
..
43e08d4
100644
(file)
--- a/
src/afb-session.c
+++ b/
src/afb-session.c
@@
-53,10
+53,10
@@
struct afb_session
int timeout;
time_t expiration; // expiration time of the token
pthread_mutex_t mutex;
int timeout;
time_t expiration; // expiration time of the token
pthread_mutex_t mutex;
+ struct cookie *cookies[COOKEYCOUNT];
char idx;
char uuid[SIZEUUID]; // long term authentication of remote client
char token[SIZEUUID]; // short term authentication of remote client
char idx;
char uuid[SIZEUUID]; // long term authentication of remote client
char token[SIZEUUID]; // short term authentication of remote client
- struct cookie *cookies[COOKEYCOUNT];
};
// Session UUID are store in a simple array [for 10 sessions this should be enough]
};
// Session UUID are store in a simple array [for 10 sessions this should be enough]
@@
-88,21
+88,18
@@
static inline void unlock(struct afb_session *session)
}
// Free context [XXXX Should be protected again memory abort XXXX]
}
// Free context [XXXX Should be protected again memory abort XXXX]
-static void
remove_all_cookies
(struct afb_session *session)
+static void
close_session
(struct afb_session *session)
{
int idx;
{
int idx;
- struct cookie *cookie
, *next
;
+ struct cookie *cookie;
- /
/ free cookies
+ /
* free cookies */
for (idx = 0 ; idx < COOKEYCOUNT ; idx++) {
for (idx = 0 ; idx < COOKEYCOUNT ; idx++) {
- cookie = session->cookies[idx];
- session->cookies[idx] = NULL;
- while (cookie != NULL) {
- next = cookie->next;
+ while ((cookie = session->cookies[idx])) {
+ session->cookies[idx] = cookie->next;
if (cookie->freecb != NULL)
cookie->freecb(cookie->value);
free(cookie);
if (cookie->freecb != NULL)
cookie->freecb(cookie->value);
free(cookie);
- cookie = next;
}
}
}
}
}
}
@@
-162,7
+159,7
@@
static void destroy (struct afb_session *session)
assert (session != NULL);
assert (session != NULL);
-
remove_all_cookies
(session);
+
close_session
(session);
pthread_mutex_lock(&sessions.mutex);
prv = &sessions.heads[(int)session->idx];
while (*prv)
pthread_mutex_lock(&sessions.mutex);
prv = &sessions.heads[(int)session->idx];
while (*prv)
@@
-255,6
+252,8
@@
static struct afb_session *add_session (const char *uuid, int timeout, time_t no
strcpy(session->token, sessions.initok);
session->timeout = timeout;
session->expiration = expiration;
strcpy(session->token, sessions.initok);
session->timeout = timeout;
session->expiration = expiration;
+
+ /* link */
session->idx = (char)idx;
session->next = sessions.heads[idx];
sessions.heads[idx] = session;
session->idx = (char)idx;
session->next = sessions.heads[idx];
sessions.heads[idx] = session;
@@
-371,8
+370,9
@@
void afb_session_close (struct afb_session *session)
pthread_mutex_lock(&session->mutex);
if (session->uuid[0] != 0) {
session->uuid[0] = 0;
pthread_mutex_lock(&session->mutex);
if (session->uuid[0] != 0) {
session->uuid[0] = 0;
- remove_all_cookies(session);
- if (session->refcount == 0) {
+ if (session->refcount)
+ close_session(session);
+ else {
destroy (session);
return;
}
destroy (session);
return;
}