From: Adam Dickmeiss Date: Wed, 17 Feb 2010 16:05:03 +0000 (+0100) Subject: Protect session_watch X-Git-Tag: v1.4.0~126^2~12 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=6876f560fb1e25e6190f84343bb4289f7b645699;p=pazpar2-moved-to-github.git Protect session_watch --- diff --git a/src/session.c b/src/session.c index bb0e915..de9efd7 100644 --- a/src/session.c +++ b/src/session.c @@ -395,17 +395,26 @@ int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *chan) { + int ret; + session_enter(s); if (s->watchlist[what].fun) - return -1; - s->watchlist[what].fun = fun; - s->watchlist[what].data = data; - s->watchlist[what].obs = http_add_observer(chan, &s->watchlist[what], - session_watch_cancel); + ret = -1; + else + { + + s->watchlist[what].fun = fun; + s->watchlist[what].data = data; + s->watchlist[what].obs = http_add_observer(chan, &s->watchlist[what], + session_watch_cancel); + ret = 0; + } + session_leave(s); return 0; } void session_alert_watch(struct session *s, int what) { + session_enter(s); if (s->watchlist[what].fun) { /* our watch is no longer associated with http_channel */ @@ -422,8 +431,11 @@ void session_alert_watch(struct session *s, int what) s->watchlist[what].data = 0; s->watchlist[what].obs = 0; + session_leave(s); fun(data); } + else + session_leave(s); } //callback for grep_databases