diff --git a/src/sipevent/listen.c b/src/sipevent/listen.c index 2224728..6f858b9 100644 --- a/src/sipevent/listen.c +++ b/src/sipevent/listen.c @@ -279,9 +279,7 @@ static void subscribe_handler(struct sipevent_sock *sock, (void)sipnot_reply(not, msg, 200, "OK"); - if (expires > 0) { - (void)sipnot_notify(not); - } + (void)sipnot_notify(not); } diff --git a/src/sipevent/notify.c b/src/sipevent/notify.c index 8c2fbf1..fa3fc0f 100644 --- a/src/sipevent/notify.c +++ b/src/sipevent/notify.c @@ -110,11 +110,11 @@ static void tmr_handler(void *arg) void sipnot_refresh(struct sipnot *not, uint32_t expires) { - expires = min(expires, not->expires_max); + not->expires = min(expires, not->expires_max); - re_printf("will expire in %u secs\n", expires); + re_printf("will expire in %u secs\n", not->expires); - tmr_start(¬->tmr, expires * 1000, tmr_handler, not); + tmr_start(¬->tmr, not->expires * 1000, tmr_handler, not); } @@ -276,6 +276,11 @@ static int notify_request(struct sipnot *not, bool reset_ls) int sipnot_notify(struct sipnot *not) { + if (not->expires == 0) { + re_printf("NOTIFY will be sent at timeout\n"); + return 0; + } + if (not->req) { re_printf("waiting for previous request to complete\n"); not->notify_pending = true; diff --git a/src/sipevent/sipevent.h b/src/sipevent/sipevent.h index 189590c..85a2a97 100644 --- a/src/sipevent/sipevent.h +++ b/src/sipevent/sipevent.h @@ -35,6 +35,7 @@ struct sipnot { char *ctype; sipevent_close_h *closeh; void *arg; + uint32_t expires; uint32_t expires_min; uint32_t expires_dfl; uint32_t expires_max;