فهرست منبع

lib/srdb1/schema, modules_k/presence, utils/kamctl: Added another field to active_watchers DB

- Added the updated_winfo field (part of the presence notifier
  fix) now to get in before the freeze.
- Also updated active_watchers table version.
Peter Dunkley 13 سال پیش
والد
کامیت
6583dd7869

+ 14 - 1
lib/srdb1/schema/pr_active_watchers.xml

@@ -9,7 +9,7 @@
 
 <table id="active_watchers" xmlns:db="http://docbook.org/ns/docbook">
     <name>active_watchers</name>
-    <version>10</version>
+    <version>11</version>
     <type db="mysql">&MYSQL_TABLE_TYPE;</type>
     <description>
         <db:para>Table for the presence module. More information can be found at: &KAMAILIO_MOD_DOC;presence.html
@@ -193,6 +193,13 @@
         <description>Update flag</description>
     </column>
 
+    <column id="updated_winfo">
+        <name>updated_winfo</name>
+        <type>int</type>
+        <size>&expires_len;</size>
+        <description>Update winfo flag</description>
+    </column>
+
     <index>
         <name>active_watchers_idx</name>
         <colref linkend="callid"/>
@@ -217,4 +224,10 @@
         <colref linkend="updated"/>
     </index>
 
+    <index>
+        <name>updated_winfo_idx</name>
+        <colref linkend="updated_winfo"/>
+	<colref linkend="presentity_uri"/>
+    </index>
+
 </table>

+ 2 - 0
modules_k/presence/notify.c

@@ -95,6 +95,8 @@ str str_inserted_time_col = str_init("inserted_time");
 str str_received_time_col = str_init("received_time");
 str str_id_col = str_init("id");
 str str_sender_col = str_init("sender");
+str str_updated_col = str_init("updated");
+str str_updated_winfo_col = str_init("updated_winfo");
 
 char* get_status_str(int status_flag)
 {

+ 2 - 0
modules_k/presence/notify.h

@@ -99,6 +99,8 @@ extern str str_inserted_time_col;
 extern str str_received_time_col;
 extern str str_id_col;
 extern str str_sender_col;
+extern str str_updated_col;
+extern str str_updated_winfo_col;
 
 void PRINT_DLG(FILE* out, dlg_t* _d);
 

+ 1 - 1
modules_k/presence/presence.c

@@ -77,7 +77,7 @@ MODULE_VERSION
 
 #define S_TABLE_VERSION  3
 #define P_TABLE_VERSION  3
-#define ACTWATCH_TABLE_VERSION 10
+#define ACTWATCH_TABLE_VERSION 11
 #define XCAP_TABLE_VERSION 4
 
 char *log_buf = NULL;

+ 29 - 5
modules_k/presence/subscribe.c

@@ -188,7 +188,7 @@ int insert_subs_db(subs_t* s, int type)
 		callid_col, totag_col, fromtag_col, event_col,status_col, event_id_col, 
 		local_cseq_col, remote_cseq_col, expires_col, record_route_col, 
 		contact_col, local_contact_col, version_col,socket_info_col,reason_col,
-		watcher_user_col, watcher_domain_col;
+		watcher_user_col, watcher_domain_col, updated_col, updated_winfo_col;
 		
 	if(pa_dbf.use_table(pa_db, &active_watchers_table)< 0)
 	{
@@ -305,7 +305,17 @@ int insert_subs_db(subs_t* s, int type)
 	query_vals[version_col].type = DB1_INT;
 	query_vals[version_col].nul = 0;
 	n_query_cols++;
-	
+
+	query_cols[updated_col= n_query_cols]=&str_updated_col;
+	query_vals[updated_col].type = DB1_INT;
+	query_vals[updated_col].nul = 0;
+	n_query_cols++;
+
+	query_cols[updated_winfo_col= n_query_cols]=&str_updated_winfo_col;
+	query_vals[updated_winfo_col].type = DB1_INT;
+	query_vals[updated_winfo_col].nul = 0;
+	n_query_cols++;
+
 	query_vals[pres_uri_col].val.str_val= s->pres_uri;
 	query_vals[callid_col].val.str_val= s->callid;
 	query_vals[totag_col].val.str_val= s->to_tag;
@@ -328,6 +338,8 @@ int insert_subs_db(subs_t* s, int type)
 	query_vals[status_col].val.int_val= s->status;
 	query_vals[reason_col].val.str_val= s->reason;
 	query_vals[socket_info_col].val.str_val= s->sockinfo_str;
+	query_vals[updated_col].val.int_val = -1;
+	query_vals[updated_winfo_col].val.int_val = -1;
 
 	if (pa_dbf.use_table(pa_db, &active_watchers_table) < 0)
 	{
@@ -1673,15 +1685,15 @@ void update_db_subs_timer_dbnone(int no_lock)
 void update_db_subs_timer(db1_con_t *db,db_func_t dbf, shtable_t hash_table,
 	int htable_size, int no_lock, handle_expired_func_t handle_expired_func)
 {
-	db_key_t query_cols[24], update_cols[7];
-	db_val_t query_vals[24], update_vals[7];
+	db_key_t query_cols[24], update_cols[6];
+	db_val_t query_vals[24], update_vals[6];
 	db_op_t update_ops[1];
 	subs_t* del_s;
 	int pres_uri_col, to_user_col, to_domain_col, from_user_col, from_domain_col,
 		callid_col, totag_col, fromtag_col, event_col,status_col, event_id_col,
 		local_cseq_col, remote_cseq_col, expires_col, record_route_col,
 		contact_col, local_contact_col, version_col,socket_info_col,reason_col,
-		watcher_user_col, watcher_domain_col;
+		watcher_user_col, watcher_domain_col, updated_col, updated_winfo_col;
 	int u_expires_col, u_local_cseq_col, u_remote_cseq_col, u_version_col,
 		u_reason_col, u_status_col;
 	int i;
@@ -1804,6 +1816,16 @@ void update_db_subs_timer(db1_con_t *db,db_func_t dbf, shtable_t hash_table,
 	query_vals[version_col].nul = 0;
 	n_query_cols++;
 
+	query_cols[updated_col= n_query_cols]=&str_updated_col;
+	query_vals[updated_col].type = DB1_INT;
+	query_vals[updated_col].nul = 0;
+	n_query_cols++;
+
+	query_cols[updated_winfo_col= n_query_cols]=&str_updated_winfo_col;
+	query_vals[updated_winfo_col].type = DB1_INT;
+	query_vals[updated_winfo_col].nul = 0;
+	n_query_cols++;
+
 	/* cols and values used for update */
 	update_cols[u_expires_col= n_update_cols]= &str_expires_col;
 	update_vals[u_expires_col].type = DB1_INT;
@@ -1921,6 +1943,8 @@ void update_db_subs_timer(db1_con_t *db,db_func_t dbf, shtable_t hash_table,
 					query_vals[status_col].val.int_val= s->status;
 					query_vals[reason_col].val.str_val= s->reason;
 					query_vals[socket_info_col].val.str_val= s->sockinfo_str;
+					query_vals[updated_col].val.int_val = -1;
+					query_vals[updated_winfo_col].val.int_val = -1;
 
 					if(dbf.insert(db,query_cols,query_vals,n_query_cols )<0)
 					{

+ 2 - 2
utils/kamctl/db_berkeley/kamailio/active_watchers

@@ -1,5 +1,5 @@
 METADATA_COLUMNS
-id(int) presentity_uri(str) watcher_username(str) watcher_domain(str) to_user(str) to_domain(str) event(str) event_id(str) to_tag(str) from_tag(str) callid(str) local_cseq(int) remote_cseq(int) contact(str) record_route(str) expires(int) status(int) reason(str) version(int) socket_info(str) local_contact(str) from_user(str) from_domain(str) updated(int)
+id(int) presentity_uri(str) watcher_username(str) watcher_domain(str) to_user(str) to_domain(str) event(str) event_id(str) to_tag(str) from_tag(str) callid(str) local_cseq(int) remote_cseq(int) contact(str) record_route(str) expires(int) status(int) reason(str) version(int) socket_info(str) local_contact(str) from_user(str) from_domain(str) updated(int) updated_winfo(int)
 METADATA_KEY
 1 6 
 METADATA_READONLY
@@ -7,4 +7,4 @@ METADATA_READONLY
 METADATA_LOGFLAGS
 0
 METADATA_DEFAULTS
-NIL|NIL|NIL|NIL|NIL|NIL|'presence'|NIL|NIL|NIL|NIL|NIL|NIL|NIL|NIL|NIL|2|NIL|0|NIL|NIL|NIL|NIL|NIL
+NIL|NIL|NIL|NIL|NIL|NIL|'presence'|NIL|NIL|NIL|NIL|NIL|NIL|NIL|NIL|NIL|2|NIL|0|NIL|NIL|NIL|NIL|NIL|NIL

+ 1 - 1
utils/kamctl/db_berkeley/kamailio/version

@@ -11,7 +11,7 @@ NIL|0
 acc|
 acc|4
 active_watchers|
-active_watchers|10
+active_watchers|11
 address|
 address|5
 aliases|

+ 3 - 1
utils/kamctl/db_sqlite/presence-create.sql

@@ -15,7 +15,7 @@ CREATE TABLE presentity (
 CREATE INDEX presentity_presentity_expires ON presentity (expires);
 CREATE INDEX presentity_account_idx ON presentity (username, domain, event);
 
-INSERT INTO version (table_name, table_version) values ('active_watchers','10');
+INSERT INTO version (table_name, table_version) values ('active_watchers','11');
 CREATE TABLE active_watchers (
     id INTEGER PRIMARY KEY NOT NULL,
     presentity_uri VARCHAR(128) NOT NULL,
@@ -41,12 +41,14 @@ CREATE TABLE active_watchers (
     from_user VARCHAR(64) NOT NULL,
     from_domain VARCHAR(64) NOT NULL,
     updated INTEGER NOT NULL,
+    updated_winfo INTEGER NOT NULL,
     CONSTRAINT active_watchers_active_watchers_idx UNIQUE (callid, to_tag, from_tag)
 );
 
 CREATE INDEX active_watchers_active_watchers_expires ON active_watchers (expires);
 CREATE INDEX active_watchers_active_watchers_pres ON active_watchers (presentity_uri);
 CREATE INDEX active_watchers_updated_idx ON active_watchers (updated);
+CREATE INDEX active_watchers_updated_winfo_idx ON active_watchers (updated_winfo, presentity_uri);
 
 INSERT INTO version (table_name, table_version) values ('watchers','3');
 CREATE TABLE watchers (

+ 1 - 1
utils/kamctl/dbtext/kamailio/active_watchers

@@ -1 +1 @@
-id(int,auto) presentity_uri(string) watcher_username(string) watcher_domain(string) to_user(string) to_domain(string) event(string) event_id(string,null) to_tag(string) from_tag(string) callid(string) local_cseq(int) remote_cseq(int) contact(string) record_route(string,null) expires(int) status(int) reason(string) version(int) socket_info(string) local_contact(string) from_user(string) from_domain(string) updated(int) 
+id(int,auto) presentity_uri(string) watcher_username(string) watcher_domain(string) to_user(string) to_domain(string) event(string) event_id(string,null) to_tag(string) from_tag(string) callid(string) local_cseq(int) remote_cseq(int) contact(string) record_route(string,null) expires(int) status(int) reason(string) version(int) socket_info(string) local_contact(string) from_user(string) from_domain(string) updated(int) updated_winfo(int) 

+ 1 - 1
utils/kamctl/dbtext/kamailio/version

@@ -1,6 +1,6 @@
 table_name(string) table_version(int) 
 acc:4
-active_watchers:10
+active_watchers:11
 address:5
 aliases:5
 carrier_name:1

+ 3 - 1
utils/kamctl/mysql/presence-create.sql

@@ -15,7 +15,7 @@ CREATE TABLE presentity (
 CREATE INDEX presentity_expires ON presentity (expires);
 CREATE INDEX account_idx ON presentity (username, domain, event);
 
-INSERT INTO version (table_name, table_version) values ('active_watchers','10');
+INSERT INTO version (table_name, table_version) values ('active_watchers','11');
 CREATE TABLE active_watchers (
     id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
     presentity_uri VARCHAR(128) NOT NULL,
@@ -41,12 +41,14 @@ CREATE TABLE active_watchers (
     from_user VARCHAR(64) NOT NULL,
     from_domain VARCHAR(64) NOT NULL,
     updated INT(11) NOT NULL,
+    updated_winfo INT(11) NOT NULL,
     CONSTRAINT active_watchers_idx UNIQUE (callid, to_tag, from_tag)
 ) ENGINE=MyISAM;
 
 CREATE INDEX active_watchers_expires ON active_watchers (expires);
 CREATE INDEX active_watchers_pres ON active_watchers (presentity_uri);
 CREATE INDEX updated_idx ON active_watchers (updated);
+CREATE INDEX updated_winfo_idx ON active_watchers (updated_winfo, presentity_uri);
 
 INSERT INTO version (table_name, table_version) values ('watchers','3');
 CREATE TABLE watchers (

+ 3 - 1
utils/kamctl/oracle/presence-create.sql

@@ -23,7 +23,7 @@ BEGIN map2users('presentity'); END;
 CREATE INDEX presentity_presentity_expires  ON presentity (expires);
 CREATE INDEX presentity_account_idx  ON presentity (username, domain, event);
 
-INSERT INTO version (table_name, table_version) values ('active_watchers','10');
+INSERT INTO version (table_name, table_version) values ('active_watchers','11');
 CREATE TABLE active_watchers (
     id NUMBER(10) PRIMARY KEY,
     presentity_uri VARCHAR2(128),
@@ -49,6 +49,7 @@ CREATE TABLE active_watchers (
     from_user VARCHAR2(64),
     from_domain VARCHAR2(64),
     updated NUMBER(10),
+    updated_winfo NUMBER(10),
     CONSTRAINT ORA_active_watchers_idx  UNIQUE (callid, to_tag, from_tag)
 );
 
@@ -63,6 +64,7 @@ BEGIN map2users('active_watchers'); END;
 CREATE INDEX ORA_active_watchers_expires  ON active_watchers (expires);
 CREATE INDEX ORA_active_watchers_pres  ON active_watchers (presentity_uri);
 CREATE INDEX active_watchers_updated_idx  ON active_watchers (updated);
+CREATE INDEX ORA_updated_winfo_idx  ON active_watchers (updated_winfo, presentity_uri);
 
 INSERT INTO version (table_name, table_version) values ('watchers','3');
 CREATE TABLE watchers (

+ 3 - 1
utils/kamctl/postgres/presence-create.sql

@@ -15,7 +15,7 @@ CREATE TABLE presentity (
 CREATE INDEX presentity_presentity_expires ON presentity (expires);
 CREATE INDEX presentity_account_idx ON presentity (username, domain, event);
 
-INSERT INTO version (table_name, table_version) values ('active_watchers','10');
+INSERT INTO version (table_name, table_version) values ('active_watchers','11');
 CREATE TABLE active_watchers (
     id SERIAL PRIMARY KEY NOT NULL,
     presentity_uri VARCHAR(128) NOT NULL,
@@ -41,12 +41,14 @@ CREATE TABLE active_watchers (
     from_user VARCHAR(64) NOT NULL,
     from_domain VARCHAR(64) NOT NULL,
     updated INTEGER NOT NULL,
+    updated_winfo INTEGER NOT NULL,
     CONSTRAINT active_watchers_active_watchers_idx UNIQUE (callid, to_tag, from_tag)
 );
 
 CREATE INDEX active_watchers_active_watchers_expires ON active_watchers (expires);
 CREATE INDEX active_watchers_active_watchers_pres ON active_watchers (presentity_uri);
 CREATE INDEX active_watchers_updated_idx ON active_watchers (updated);
+CREATE INDEX active_watchers_updated_winfo_idx ON active_watchers (updated_winfo, presentity_uri);
 
 INSERT INTO version (table_name, table_version) values ('watchers','3');
 CREATE TABLE watchers (