diff --git a/include/re_sipevent.h b/include/re_sipevent.h index fdd7503..8f60470 100644 --- a/include/re_sipevent.h +++ b/include/re_sipevent.h @@ -77,7 +77,8 @@ struct sipsub; typedef int (sipevent_fork_h)(struct sipsub **subp, struct sipsub *osub, const struct sip_msg *msg, void *arg); -typedef void (sipevent_notify_h)(const struct sip_msg *msg, void *arg); +typedef void (sipevent_notify_h)(struct sip *sip, const struct sip_msg *msg, + void *arg); int sipevent_subscribe(struct sipsub **subp, struct sipevent_sock *sock, const char *uri, const char *from_name, diff --git a/src/sipevent/listen.c b/src/sipevent/listen.c index b2d4e78..2224728 100644 --- a/src/sipevent/listen.c +++ b/src/sipevent/listen.c @@ -192,11 +192,13 @@ static void notify_handler(struct sipevent_sock *sock, (void)sip_dialog_update(sub->dlg, msg); } - (void)sip_treply(NULL, sip, msg, 200, "OK"); - if (sub->refer_cseq >= 0 && !sub->id && pl_isset(&event.id)) { - (void)pl_strdup(&sub->id, &event.id); + err = pl_strdup(&sub->id, &event.id); + if (err) { + (void)sip_treply(NULL, sip, msg, 500, strerror(err)); + return; + } } re_printf("notify: %s (%r)\n", sipevent_substate_name(state.state), @@ -217,11 +219,8 @@ static void notify_handler(struct sipevent_sock *sock, break; } - if (sub->terminated) - return; - mem_ref(sub); - sub->notifyh(msg, sub->arg); + sub->notifyh(sip, msg, sub->arg); nrefs = mem_nrefs(sub); mem_deref(sub); diff --git a/src/sipevent/subscribe.c b/src/sipevent/subscribe.c index e650da9..a871739 100644 --- a/src/sipevent/subscribe.c +++ b/src/sipevent/subscribe.c @@ -29,10 +29,12 @@ enum { static int request(struct sipsub *sub, bool reset_ls); -static void internal_notify_handler(const struct sip_msg *msg, void *arg) +static void internal_notify_handler(struct sip *sip, const struct sip_msg *msg, + void *arg) { - (void)msg; (void)arg; + + (void)sip_treply(NULL, sip, msg, 200, "OK"); }