summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-03-31 11:55:20 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-03-31 11:55:20 +0200
commit20ea5089d0e5526afaa5231f30add7b25b2499bd (patch)
tree1e2cc4cb1373647b10721ea4ed434162fbbc3ffc
parentc9ba2ce49808a19a4ef982280a46256797b830ae (diff)
Allow detection of session closure
In some case it can be good to have a function called when the session closes. This is the case when a binding records an item in the context. With this modification the recorded item can be simply NULL. Change-Id: I5e23f00eb2a6e2639fdeea15f9dea79c7df9dfbb Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-session.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/afb-session.c b/src/afb-session.c
index 07092cea..bc1c1c5f 100644
--- a/src/afb-session.c
+++ b/src/afb-session.c
@@ -98,7 +98,7 @@ static void free_data (struct afb_session *session)
session->cookies[idx] = NULL;
while (cookie != NULL) {
next = cookie->next;
- if (cookie->value != NULL && cookie->freecb != NULL)
+ if (cookie->freecb != NULL)
cookie->freecb(cookie->value);
free(cookie);
cookie = next;
@@ -420,7 +420,7 @@ int afb_session_set_cookie(struct afb_session *session, const void *key, void *v
cookie = session->cookies[idx];
while(cookie != NULL) {
if (cookie->key == key) {
- if (cookie->value != NULL && cookie->value != value && cookie->freecb != NULL)
+ if (cookie->value != value && cookie->freecb)
cookie->freecb(cookie->value);
cookie->value = value;
cookie->freecb = freecb;