Skip to content

Commit b72e645

Browse files
committed
change: sip_subscribe_remove on close
1 parent 504e2ad commit b72e645

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

libsip/include/sip-uac.h

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct sip_uac_transaction_t;
1515
/// @param[out] session user-defined session-id(only code=2xx)
1616
/// @return 0-ok, other-error
1717
typedef int (*sip_uac_oninvite)(void* param, const struct sip_message_t* reply, struct sip_uac_transaction_t* t, struct sip_dialog_t* dialog, int code, void** session);
18+
/// @param[in] subscribe MUST call sip_subscribe_remove on close
1819
/// @param[out] session user-defined session-id(only code=2xx)
1920
/// @return 0-ok, other-error
2021
typedef int (*sip_uac_onsubscribe)(void* param, const struct sip_message_t* reply, struct sip_uac_transaction_t* t, struct sip_subscribe_t* subscribe, int code, void** session);

libsip/src/uac/sip-uac-subscribe.c

+14-10
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@ int sip_uac_subscribe_onreply(struct sip_uac_transaction_t* t, const struct sip_
2929
}
3030
else
3131
{
32-
r = t->onsubscribe(t->param, reply, t, NULL, reply->u.s.code, NULL);
32+
// for subscribe expires 0, to sip_subscribe_remove
33+
subscribe = sip_subscribe_fetch(t->agent, &t->req->callid, &t->req->from.tag, &t->req->to.tag, &t->req->event);
34+
35+
r = t->onsubscribe(t->param, reply, t, subscribe, reply->u.s.code, subscribe ? &subscribe->evtsession : NULL);
3336
}
3437

3538
if (subscribe)
3639
{
37-
// delete subscribe if expires is 0
38-
h = sip_message_get_header_by_name(t->req, "Expires");
39-
if (h && 0 == cstrtol(h, NULL, 10))
40-
{
41-
sip_subscribe_remove(t->agent, subscribe);
42-
assert(1 == subscribe->ref);
43-
}
40+
// It's user due to remove subscribe on expires 0
41+
//// delete subscribe if expires is 0
42+
//h = sip_message_get_header_by_name(t->req, "Expires");
43+
//if (h && 0 == cstrtol(h, NULL, 10))
44+
//{
45+
// sip_subscribe_remove(t->agent, subscribe);
46+
// assert(1 == subscribe->ref);
47+
//}
4448

4549
sip_subscribe_release(subscribe);
4650
}
@@ -66,8 +70,8 @@ int sip_uac_notify_onreply(struct sip_uac_transaction_t* t, const struct sip_mes
6670
// NOTICE: ignore notify before subscribe created
6771
r = t->onreply(t->param, reply, t, reply->u.s.code);
6872

69-
if (0 == cstrcmp(&reply->substate.state, SIP_SUBSCRIPTION_STATE_TERMINATED))
70-
sip_subscribe_remove(t->agent, subscribe);
73+
//if (0 == cstrcmp(&reply->substate.state, SIP_SUBSCRIPTION_STATE_TERMINATED))
74+
// sip_subscribe_remove(t->agent, subscribe);
7175

7276
sip_subscribe_release(subscribe);
7377
return r;

libsip/src/uas/sip-uas-subscribe.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ int sip_uas_onsubscribe(struct sip_uas_transaction_t* t, struct sip_dialog_t* di
3434
// notify expire
3535
//if (t->handler->onnotify)
3636
// t->handler->onnotify(param, req, t, subscribe->evtsession, NULL);
37-
sip_subscribe_remove(t->agent, subscribe);
38-
assert(1 == subscribe->ref);
37+
38+
// It's user due to remove subscribe on expires 0
39+
//sip_subscribe_remove(t->agent, subscribe);
40+
//assert(1 == subscribe->ref);
3941
}
4042

4143
sip_subscribe_release(subscribe);
@@ -74,8 +76,8 @@ int sip_uas_onnotify(struct sip_uas_transaction_t* t, const struct sip_message_t
7476
else
7577
r = 0; // just ignore
7678

77-
if (subscribe && 0 == cstrcmp(&req->substate.state, SIP_SUBSCRIPTION_STATE_TERMINATED))
78-
sip_subscribe_remove(t->agent, subscribe);
79+
//if (subscribe && 0 == cstrcmp(&req->substate.state, SIP_SUBSCRIPTION_STATE_TERMINATED))
80+
// sip_subscribe_remove(t->agent, subscribe);
7981

8082
sip_subscribe_release(subscribe);
8183
return r;

0 commit comments

Comments
 (0)