git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2384 689a6050-402a-0410-94f2-e92a70836424
... | ... |
@@ -139,6 +139,7 @@ int add_event(ev_t* event) |
139 | 139 |
ev->is_watcher_allowed= event->is_watcher_allowed; |
140 | 140 |
ev->evs_publ_handl= event->evs_publ_handl; |
141 | 141 |
ev->etag_not_new= event->etag_not_new; |
142 |
+ ev->free_body= event->free_body; |
|
142 | 143 |
ev->next= EvList->events; |
143 | 144 |
EvList->events= ev; |
144 | 145 |
EvList->ev_count++; |
... | ... |
@@ -58,6 +58,9 @@ typedef int (is_allowed_t)(struct subscription* subs); |
58 | 58 |
* >0 if change in status |
59 | 59 |
* */ |
60 | 60 |
|
61 |
+/* event specific body free function */ |
|
62 |
+typedef void(free_body_t)(char* body); |
|
63 |
+ |
|
61 | 64 |
struct ev |
62 | 65 |
{ |
63 | 66 |
str name; |
... | ... |
@@ -89,7 +92,7 @@ struct ev |
89 | 92 |
agg_nbody_t* agg_nbody; |
90 | 93 |
publ_handling_t * evs_publ_handl; |
91 | 94 |
subs_handling_t * evs_subs_handl; |
92 |
- |
|
95 |
+ free_body_t* free_body; |
|
93 | 96 |
struct ev* wipeer; |
94 | 97 |
struct ev* next; |
95 | 98 |
|
... | ... |
@@ -684,7 +684,7 @@ dlg_t* build_dlg_t (str p_uri, subs_t* subs) |
684 | 684 |
} |
685 | 685 |
memset(td, 0, sizeof(dlg_t)); |
686 | 686 |
|
687 |
- td->loc_seq.value = subs->cseq+ 1; |
|
687 |
+ td->loc_seq.value = subs->cseq++; |
|
688 | 688 |
td->loc_seq.is_set = 1; |
689 | 689 |
|
690 | 690 |
td->id.call_id = subs->callid; |
... | ... |
@@ -1108,7 +1108,7 @@ done: |
1108 | 1108 |
if(notify_body!=NULL) |
1109 | 1109 |
{ |
1110 | 1110 |
if(notify_body->s) |
1111 |
- free(notify_body->s); |
|
1111 |
+ p->event->free_body(notify_body->s); |
|
1112 | 1112 |
pkg_free(notify_body); |
1113 | 1113 |
} |
1114 | 1114 |
|
... | ... |
@@ -1127,7 +1127,7 @@ error: |
1127 | 1127 |
if(notify_body!=NULL) |
1128 | 1128 |
{ |
1129 | 1129 |
if(notify_body->s) |
1130 |
- free(notify_body->s); |
|
1130 |
+ p->event->free_body(notify_body->s); |
|
1131 | 1131 |
pkg_free(notify_body); |
1132 | 1132 |
} |
1133 | 1133 |
return -1; |
... | ... |
@@ -1191,7 +1191,7 @@ done: |
1191 | 1191 |
if(notify_body!=NULL) |
1192 | 1192 |
{ |
1193 | 1193 |
if(notify_body->s) |
1194 |
- free(notify_body->s); |
|
1194 |
+ event->free_body(notify_body->s); |
|
1195 | 1195 |
pkg_free(notify_body); |
1196 | 1196 |
} |
1197 | 1197 |
|
... | ... |
@@ -1210,7 +1210,7 @@ error: |
1210 | 1210 |
if(notify_body!=NULL) |
1211 | 1211 |
{ |
1212 | 1212 |
if(notify_body->s) |
1213 |
- free(notify_body->s); |
|
1213 |
+ event->free_body(notify_body->s); |
|
1214 | 1214 |
pkg_free(notify_body); |
1215 | 1215 |
} |
1216 | 1216 |
return -1; |
... | ... |
@@ -1379,7 +1379,7 @@ jump_over_body: |
1379 | 1379 |
update_keys[n_update_keys] = "local_cseq"; |
1380 | 1380 |
update_vals[n_update_keys].type = DB_INT; |
1381 | 1381 |
update_vals[n_update_keys].nul = 0; |
1382 |
- update_vals[n_update_keys].val.int_val = subs->cseq +1; |
|
1382 |
+ update_vals[n_update_keys].val.int_val = subs->cseq; |
|
1383 | 1383 |
n_update_keys++; |
1384 | 1384 |
|
1385 | 1385 |
update_keys[n_update_keys] = "status"; |
... | ... |
@@ -1388,7 +1388,6 @@ jump_over_body: |
1388 | 1388 |
update_vals[n_update_keys].val.str_val = subs->status; |
1389 | 1389 |
n_update_keys++; |
1390 | 1390 |
|
1391 |
- |
|
1392 | 1391 |
if(subs->event->type & WINFO_TYPE) |
1393 | 1392 |
{ |
1394 | 1393 |
update_keys[n_update_keys] = "version"; |
... | ... |
@@ -1425,10 +1424,7 @@ jump_over_body: |
1425 | 1424 |
{ |
1426 | 1425 |
if(notify_body->s!=NULL) |
1427 | 1426 |
{ |
1428 |
- if(subs->event->agg_nbody!=NULL) |
|
1429 |
- free(notify_body->s); |
|
1430 |
- else |
|
1431 |
- pkg_free(notify_body->s); |
|
1427 |
+ subs->event->free_body(notify_body->s); |
|
1432 | 1428 |
} |
1433 | 1429 |
pkg_free(notify_body); |
1434 | 1430 |
} |
... | ... |
@@ -1457,7 +1453,7 @@ error: |
1457 | 1453 |
if(notify_body!=NULL) |
1458 | 1454 |
{ |
1459 | 1455 |
if(notify_body->s!=NULL) |
1460 |
- free(notify_body->s); |
|
1456 |
+ subs->event->free_body(notify_body->s); |
|
1461 | 1457 |
pkg_free(notify_body); |
1462 | 1458 |
} |
1463 | 1459 |
} |
... | ... |
@@ -250,7 +250,8 @@ int update_subscription(struct sip_msg* msg, subs_t* subs, str *rtag, |
250 | 250 |
" notify for winfo\n"); |
251 | 251 |
goto error; |
252 | 252 |
} |
253 |
- } |
|
253 |
+ } |
|
254 |
+ |
|
254 | 255 |
} |
255 | 256 |
else /* if unsubscribe for winfo */ |
256 | 257 |
{ |
... | ... |
@@ -261,6 +262,14 @@ int update_subscription(struct sip_msg* msg, subs_t* subs, str *rtag, |
261 | 262 |
goto error; |
262 | 263 |
} |
263 | 264 |
} |
265 |
+ |
|
266 |
+ if(notify(subs, NULL, NULL, 0)< 0) |
|
267 |
+ { |
|
268 |
+ LOG(L_ERR, "PRESENCE:update_subscription: Could not send" |
|
269 |
+ " notify \n"); |
|
270 |
+ goto error; |
|
271 |
+ } |
|
272 |
+ |
|
264 | 273 |
return 1; |
265 | 274 |
} |
266 | 275 |
|
... | ... |
@@ -1257,9 +1266,10 @@ int handle_subscribe(struct sip_msg* msg, char* str1, char* str2) |
1257 | 1266 |
" from database\n"); |
1258 | 1267 |
goto error; |
1259 | 1268 |
} |
1269 |
+ |
|
1260 | 1270 |
DBG("PRESENCE: handle_subscribe: pres_user= %.*s\t pres_domain= %.*s\n", |
1261 |
- subs.pres_user.len, subs.pres_user.s, |
|
1262 |
- subs.pres_domain.len, subs.pres_domain.s); |
|
1271 |
+ subs.pres_user.len, subs.pres_user.s, |
|
1272 |
+ subs.pres_domain.len, subs.pres_domain.s); |
|
1263 | 1273 |
} |
1264 | 1274 |
|
1265 | 1275 |
DBG("PRESENCE: handle_subscribe: local_contact: %.*s --- len= %d\n", |
... | ... |
@@ -1688,10 +1698,8 @@ int get_database_info(struct sip_msg* msg, subs_t* subs, |
1688 | 1698 |
*error_ret= 0; |
1689 | 1699 |
return -1; |
1690 | 1700 |
} |
1691 |
- else |
|
1692 |
- remote_cseq= subs->cseq; |
|
1693 | 1701 |
|
1694 |
- *rem_cseq= remote_cseq; |
|
1702 |
+ *rem_cseq= subs->cseq; |
|
1695 | 1703 |
|
1696 | 1704 |
pres_user.s= (char*)row_vals[pres_user_col].val.string_val; |
1697 | 1705 |
pres_user.len= strlen(pres_user.s); |
... | ... |
@@ -105,6 +105,13 @@ err: |
105 | 105 |
return -1; |
106 | 106 |
|
107 | 107 |
} |
108 |
+void free_mwi_body(char* body) |
|
109 |
+{ |
|
110 |
+ if(body== NULL) |
|
111 |
+ return; |
|
112 |
+ pkg_free(body); |
|
113 |
+ body= NULL; |
|
114 |
+} |
|
108 | 115 |
|
109 | 116 |
int mwi_add_events() |
110 | 117 |
{ |
... | ... |
@@ -124,6 +131,7 @@ int mwi_add_events() |
124 | 131 |
event.is_watcher_allowed = mwi_watcher_allowed; |
125 | 132 |
event.agg_nbody = 0; |
126 | 133 |
event.evs_publ_handl = mwi_publ_handl; |
134 |
+ event.free_body= free_mwi_body; |
|
127 | 135 |
|
128 | 136 |
if (pres_add_event(&event) < 0) { |
129 | 137 |
LOG(L_ERR, "presence_mwi: ERROR while adding event " |
... | ... |
@@ -62,6 +62,7 @@ int xml_add_events() |
62 | 62 |
event.is_watcher_allowed= pres_watcher_allowed; |
63 | 63 |
event.agg_nbody= pres_agg_nbody; |
64 | 64 |
event.evs_publ_handl= xml_publ_handl; |
65 |
+ event.free_body= free_xml_body; |
|
65 | 66 |
|
66 | 67 |
if(pres_add_event(&event)< 0) |
67 | 68 |
{ |
... | ... |
@@ -77,6 +78,7 @@ int xml_add_events() |
77 | 78 |
event.content_type.s= "application/watcherinfo+xml"; |
78 | 79 |
event.content_type.len= 27; |
79 | 80 |
event.type= WINFO_TYPE; |
81 |
+ event.free_body= free_xml_body; |
|
80 | 82 |
|
81 | 83 |
if(pres_add_event(&event)< 0) |
82 | 84 |
{ |
... | ... |
@@ -97,6 +99,7 @@ int xml_add_events() |
97 | 99 |
event.content_type.s= "application/dialog-info+xml"; |
98 | 100 |
event.content_type.len= 27; |
99 | 101 |
event.type= PUBL_TYPE; |
102 |
+ event.free_body= free_xml_body; |
|
100 | 103 |
|
101 | 104 |
if(pres_add_event(&event)< 0) |
102 | 105 |
{ |
... | ... |
@@ -41,6 +41,16 @@ str* get_final_notify_body( subs_t *subs, str* notify_body, xmlNodePtr rule_node |
41 | 41 |
extern int force_active; |
42 | 42 |
extern int pidf_manipulation; |
43 | 43 |
|
44 |
+void free_xml_body(char* body) |
|
45 |
+{ |
|
46 |
+ if(body== NULL) |
|
47 |
+ return; |
|
48 |
+ |
|
49 |
+ xmlFree(body); |
|
50 |
+ body= NULL; |
|
51 |
+} |
|
52 |
+ |
|
53 |
+ |
|
44 | 54 |
str* pres_agg_nbody(str* pres_user, str* pres_domain, str** body_array, int n, int off_index) |
45 | 55 |
{ |
46 | 56 |
str* n_body= NULL; |