瀏覽代碼

- port from opensips, r4490, Credits goes to Anca Vamanu
- fixed a restart bug in presence module
- fixed not storing version field in database in pua module



git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4546 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt 17 年之前
父節點
當前提交
248e64065f
共有 4 個文件被更改,包括 34 次插入8 次删除
  1. 1 1
      modules_k/presence/notify.c
  2. 4 0
      modules_k/pua/hash.c
  3. 14 4
      modules_k/pua/pua.c
  4. 15 3
      modules_k/pua/send_subscribe.c

+ 1 - 1
modules_k/presence/notify.c

@@ -1153,7 +1153,7 @@ subs_t* get_subs_dialog(str* pres_uri, pres_ev_t* event, str* sender)
 		}
 		
 		if((!(s->status== ACTIVE_STATUS &&
-            s->reason.s == NULL && s->reason.len== 0 &&
+            s->reason.len== 0 &&
 			s->event== event && s->pres_uri.len== pres_uri->len &&
 			strncmp(s->pres_uri.s, pres_uri->s, pres_uri->len)== 0)) || 
 			(sender && sender->len== s->contact.len && 

+ 4 - 0
modules_k/pua/hash.c

@@ -44,6 +44,10 @@ void print_ua_pres(ua_pres_t* p)
 	{	
 		LM_DBG("\twatcher_uri= %.*s  len= %d\n", p->watcher_uri->len, p->watcher_uri->s, p->watcher_uri->len);
 		LM_DBG("\tcall_id= %.*s   len= %d\n", p->call_id.len, p->call_id.s, p->call_id.len);
+		LM_DBG("\tfrom_tag= %.*s   len= %d\n", p->from_tag.len, p->from_tag.s, p->from_tag.len);
+		LM_DBG("\tto_tag= %.*s  len= %d\n", p->to_tag.len, p->to_tag.s, p->to_tag.len);
+		LM_DBG("\tflag= %d\n", p->flag);
+		LM_DBG("\tevent= %d\n", p->event);
 	}	
 	else
 	{

+ 14 - 4
modules_k/pua/pua.c

@@ -90,6 +90,7 @@ static str str_contact_col= str_init("contact");
 static str str_remote_contact_col= str_init("remote_contact");
 static str str_extra_headers_col= str_init("extra_headers");
 static str str_desired_expires_col= str_init("desired_expires");
+static str str_version_col = str_init("version");
 
 /* module functions */
 
@@ -301,7 +302,7 @@ static void destroy(void)
 static int db_restore(void)
 {
 	ua_pres_t* p= NULL;
-	db_key_t result_cols[18]; 
+	db_key_t result_cols[19]; 
 	db_res_t *res= NULL;
 	db_row_t *row = NULL;	
 	db_val_t *row_vals= NULL;
@@ -315,7 +316,7 @@ static int db_restore(void)
 	int puri_col,pid_col,expires_col,flag_col,etag_col, desired_expires_col;
 	int watcher_col,callid_col,totag_col,fromtag_col,cseq_col,remote_contact_col;
 	int event_col,contact_col,tuple_col,record_route_col, extra_headers_col;
-
+	int version_col;
 
 	result_cols[puri_col=n_result_cols++]	= &str_pres_uri_col;
 	result_cols[pid_col=n_result_cols++]	= &str_pres_id_col;
@@ -334,6 +335,7 @@ static int db_restore(void)
 	result_cols[remote_contact_col= n_result_cols++]	= &str_remote_contact_col;
 	result_cols[extra_headers_col= n_result_cols++]	= &str_extra_headers_col;
 	result_cols[desired_expires_col= n_result_cols++]	= &str_desired_expires_col;
+	result_cols[version_col= n_result_cols++]	= &str_version_col;
 	
 	if(!pua_db)
 	{
@@ -525,6 +527,9 @@ static int db_restore(void)
 			}
 			memcpy(p->remote_contact.s, remote_contact.s, remote_contact.len);
 			p->remote_contact.len= remote_contact.len;
+	
+			p->version= row_vals[version_col].val.int_val;
+
 		}
 
 		if(extra_headers.s)
@@ -749,7 +754,7 @@ static void db_update(unsigned int ticks,void *param)
 	int puri_col,pid_col,expires_col,flag_col,etag_col,tuple_col,event_col;
 	int watcher_col,callid_col,totag_col,fromtag_col,record_route_col,cseq_col;
 	int no_lock= 0, contact_col, desired_expires_col, extra_headers_col;
-	int remote_contact_col;
+	int remote_contact_col, version_col;
 	
 	if(ticks== 0 && param == NULL)
 		no_lock= 1;
@@ -835,13 +840,17 @@ static void db_update(unsigned int ticks,void *param)
 	q_vals[remote_contact_col].nul = 0;
 	n_query_cols++;
 
+	q_cols[version_col= n_query_cols] = &str_version_col;
+	q_vals[version_col].type = DB_INT;
+	q_vals[version_col].nul = 0;
+	n_query_cols++;
+
 	/* must keep this the last  column to be inserted */
 	q_cols[extra_headers_col= n_query_cols] = &str_extra_headers_col;
 	q_vals[extra_headers_col].type = DB_STR;
 	q_vals[extra_headers_col].nul = 0;
 	n_query_cols++;
 
-
 	/* cols and values used for update */
 	db_cols[0]= &str_expires_col;
 	db_vals[0].type = DB_INT;
@@ -999,6 +1008,7 @@ static void db_update(unsigned int ticks,void *param)
 					q_vals[expires_col].val.int_val = p->expires;
 					q_vals[desired_expires_col].val.int_val = p->desired_expires;
 					q_vals[event_col].val.int_val = p->event;
+					q_vals[version_col].val.int_val = p->version;
 					
 					q_vals[record_route_col].val.str_val = p->record_route;
 					q_vals[contact_col].val.str_val = p->contact;

+ 15 - 3
modules_k/pua/send_subscribe.c

@@ -363,17 +363,20 @@ void subs_cback_func(struct cell *t, int cb_type, struct tmcb_params *ps)
 		   a subscription with type= INSERT_TYPE, else return*/	
 		
 		if(presentity)
-		{	
+		{
 			subs_info_t subs;
 			hentity->event= presentity->event;
 			delete_htable(presentity, hash_code);
 			lock_release(&HashT->p_records[hash_code].lock);
-		
+
 			memset(&subs, 0, sizeof(subs_info_t));
 			subs.pres_uri= hentity->pres_uri; 
 			subs.watcher_uri= hentity->watcher_uri;
 			subs.contact= &hentity->contact;
-			
+
+			if(hentity->remote_contact.s)
+				subs.remote_target= &hentity->remote_contact;
+
 			if(hentity->desired_expires== 0)
 				subs.expires= -1;
 			else
@@ -689,6 +692,9 @@ ua_pres_t* subs_cbparam_indlg(ua_pres_t* subs, int ua_flag)
 	if(subs->extra_headers && subs->extra_headers->s)
 		size+= sizeof(str)+ subs->extra_headers->len;
 
+	if(subs->remote_contact.s)
+		size+= subs->remote_contact.len;
+
 	hentity= (ua_pres_t*)shm_malloc(size);
 	if(hentity== NULL)
 	{
@@ -733,6 +739,12 @@ ua_pres_t* subs_cbparam_indlg(ua_pres_t* subs, int ua_flag)
 	{
 		CONT_COPY(hentity, hentity->id, subs->id)
 	}
+	
+	if(subs->remote_contact.s)
+	{
+		CONT_COPY(hentity, hentity->remote_contact, subs->remote_contact)
+	}
+
 	if(subs->extra_headers)
 	{
 		hentity->extra_headers= (str*)((char*)hentity+ size);