Просмотр исходного кода

rls - multiple message queues replaced with one shared
- xcap root stored into database with subscription data
pa, presence_b2b, lib: little changes in API for internal status notification (QSA)

Vaclav Kubart 19 лет назад
Родитель
Сommit
246b651022

+ 6 - 0
db/schema/rls_subscription.xml

@@ -66,6 +66,12 @@
 		<size>&uri_len;</size>
 	</column>
 	
+	<column>
+		<name>xcap_root</name>
+		<type>string</type>
+		<size>255</size>
+	</column>
+	
     <index>
 		<name>rls_subscription_key</name>
 		<colref linkend="rls_subscription.id"/>

+ 1 - 1
lib/cds/logger.h

@@ -31,7 +31,7 @@
 #include <stdio.h>
 
 #define ERROR_LOG(a,args...)		do{printf(a,##args);}while(0)
-#define DEBUG_LOG(a,args...)		do{printf(a,##args);}while(0)
+#DEFINE dEBUG_LOG(a,args...)		do{printf(a,##args);}while(0)
 #define TRACE_LOG(a,args...)		do{printf(a,##args);}while(0)
 #define WARN_LOG(a,args...)			do{printf(a,##args);}while(0)
 #define FLUSH_LOG()					do{fflush(stdout);}while(0)

+ 6 - 0
lib/presence/ChangeLog

@@ -0,0 +1,6 @@
+2006-03-20
+	* extra information (record_id, package, ...) in QSA notificaltions
+	(client_notify_info_t) replaced by pointer to subscription [may be a bit
+	problematic, but much simplier and saving memory for QSA subscriptions
+	used in PA, RLS, PRESENCE_B2B]
+

+ 0 - 41
lib/presence/client_notify_info.c

@@ -1,41 +0,0 @@
-/* 
- * Copyright (C) 2005 iptelorg GmbH
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <presence/client_notify_info.h>
-
-#include <cds/memory.h>
-#include <cds/sstr.h>
-#include <cds/logger.h>
-
-void free_client_notify_info_content(client_notify_info_t *info)
-{
-	DEBUG_LOG(" ... freeing notify info content\n");
-	str_free_content(&info->package);
-	str_free_content(&info->record_id);
-	str_free_content(&info->notifier);
-	DEBUG_LOG(" ... calling destroy func on data\n");
-	if (info->destroy_func) info->destroy_func(info->data);
-}
-

+ 0 - 48
lib/presence/client_notify_info.h

@@ -1,48 +0,0 @@
-/* 
- * Copyright (C) 2005 iptelorg GmbH
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __CLIENT_NOTIFY_INFO_H
-#define __CLIENT_NOTIFY_INFO_H
-
-/** This structure is sent via message queue
- * to client. It must contain all information
- * for processing the status info. */
-
-#include <cds/sstr.h>
-#include <cds/msg_queue.h>
-
-typedef struct {
-	str_t package;
-	str_t record_id;
-	str_t notifier;
-	void *data;
-	int data_len;
-	destroy_function_f destroy_func; /* function used to destroy data */
-} client_notify_info_t;
-
-
-void free_client_notify_info_content(client_notify_info_t *info);
-
-#endif

+ 20 - 1
lib/presence/notifier.h

@@ -59,8 +59,27 @@ void accept_subscription(subscription_t *s);
  * don't need it) */
 void release_subscription(subscription_t *s);
 
+/** This structure is sent via message queue
+ * to client. It must contain all information
+ * for processing the status info. */
+
+typedef struct {
+	/* replacement for record_id, package, ... it is much more efficient */
+	subscription_t *subscription; 
+	int data_type;
+	void *data;
+	int data_len;
+	destroy_function_f destroy_func; /* function used to destroy data */
+} client_notify_info_t;
+
+
+void free_client_notify_info_content(client_notify_info_t *info);
+
 /* notifications SHOULD be sent through this method */
-void notify_subscriber(subscription_t *s, mq_message_t *msg);
+int notify_subscriber(subscription_t *s, 
+		int data_type, 
+		void *data, int data_len, 
+		destroy_function_f data_destroy);
 
 #ifdef __cplusplus
 }

+ 49 - 5
lib/presence/notifier_domain.c

@@ -424,21 +424,65 @@ void unsubscribe(notifier_domain_t *domain, subscription_t *s)
 	release_subscription(s); 
 }
 
-void notify_subscriber(subscription_t *s, mq_message_t *msg)
+/* void notify_subscriber(subscription_t *s, mq_message_t *msg) */
+int notify_subscriber(subscription_t *s, 
+		int data_type, 
+		void *data, int data_len, 
+		destroy_function_f data_destroy)
 {
+	int ok = 1;
 	int sent = 0;
+	mq_message_t *msg = NULL;
+	client_notify_info_t* info = NULL;
+
+	if (!s) {
+		ERROR_LOG("BUG: sending notify for <null> subscription\n");
+		ok = 0;
+	}
 	
-	if (s) {
+	if (ok) {
+		msg = create_message_ex(sizeof(client_notify_info_t));
+		if (!msg) {
+			ERROR_LOG("can't create notify message!\n");
+			ok = 0; 
+		}
+	}
+	
+	if (ok) {
+		set_data_destroy_function(msg, (destroy_function_f)free_client_notify_info_content);
+		info = (client_notify_info_t*)msg->data;
+		
+		info->subscription = s;
+		info->data_type = data_type;
+		info->data = data;
+		info->data_len = data_len;
+		info->destroy_func = data_destroy;
+		
 		lock_subscription_data(s);
 		if (s->dst) {
-			push_message(s->dst, msg);
-			sent = 1;
+			if (push_message(s->dst, msg) < 0) ok = 0;
+			else sent = 1;
 		}
 		unlock_subscription_data(s);
 	}
 	
 	if (!sent) {
 		/* free unsent messages */
-		free_message(msg);
+		if (msg) free_message(msg);
+		else if (data_destroy && data) data_destroy(data);
 	}
+
+	if (ok) return 0;
+	else return 1; /* !!! Warning: data are destroyed !!! */
+}
+
+void free_client_notify_info_content(client_notify_info_t *info)
+{
+	DEBUG_LOG(" ... freeing notify info content\n");
+/*	str_free_content(&info->package);
+	str_free_content(&info->record_id);
+	str_free_content(&info->notifier); */
+	DEBUG_LOG(" ... calling destroy func on data\n");
+	if (info->destroy_func) info->destroy_func(info->data);
 }
+

+ 0 - 2
lib/presence/notifier_domain.h

@@ -32,8 +32,6 @@
 #include <cds/msg_queue.h>
 #include <cds/ref_cntr.h>
 
-#include <presence/client_notify_info.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif

+ 8 - 9
lib/presence/pres_doc.c

@@ -165,32 +165,31 @@ void free_presentity_info(presentity_info_t *p)
 	cds_free(p);
 }
 
-list_presence_info_t *create_list_presence_info(const str_t *uri)
+raw_presence_info_t *create_raw_presence_info(const str_t *uri)
 {
-	list_presence_info_t *p;
+	raw_presence_info_t *p;
 	int len = 0;
 	
 	if (!is_str_empty(uri)) len = uri->len;
-	p = (list_presence_info_t*)cds_malloc(sizeof(list_presence_info_t) + len);
+	p = (raw_presence_info_t*)cds_malloc(sizeof(raw_presence_info_t) + len);
 	if (!p) {
 		ERROR_LOG("can't allocate memory for list presence info\n");
 		return p;
 	}
-	p->list_uri.len = len;
+	p->uri.len = len;
 	if (len > 0) {
-		p->list_uri.s = p->uri_data;
-		memcpy(p->list_uri.s, uri->s, len);
+		p->uri.s = p->uri_data;
+		memcpy(p->uri.s, uri->s, len);
 	}
-	else p->list_uri.s = NULL;
+	else p->uri.s = NULL;
 	
-	/* ptr_vector_init(&p->presentity_infos, 8); */
 	str_clear(&p->pres_doc);
 	str_clear(&p->content_type);
 	
 	return p;
 }
 
-void free_list_presence_info(list_presence_info_t *p)
+void free_raw_presence_info(raw_presence_info_t *p)
 {
 	if (p) {
 		DEBUG_LOG(" ... freeing doc\n");

+ 9 - 11
lib/presence/pres_doc.h

@@ -30,6 +30,11 @@
 #include <cds/ptr_vector.h>
 #include <time.h>
 
+/* document types processed by presence subscribers
+ * and generated by presence notifiers */
+#define PRESENTITY_INFO_TYPE	1	/* structure presentity_info_t */
+#define PRESENTITY_RAW_INFO		2	/* raw document */
+
 typedef struct _presence_note_t {
 	str_t value;
 	str_t lang;
@@ -85,19 +90,12 @@ typedef struct {
 } presentity_info_t;
 
 typedef struct {
-	str_t list_uri; /* do not modify this !*/
-	
-	/* vector of pointers to structures presentity_info_t */
-	/* ptr_vector_t presentity_infos; */
-	
-	/* FIXME: the presence tree may include many lists
-	 * and may be deep - isn't better to work with
-	 * whole documents than with some structures? */
+	str_t uri; /* do not modify this !*/
 	
 	str_t pres_doc;
 	str_t content_type;
 	char uri_data[1];
-} list_presence_info_t;
+} raw_presence_info_t;
 
 typedef struct {
 	str_t list_uri; /* do not modify this !*/
@@ -112,8 +110,8 @@ presence_tuple_info_t *create_tuple_info(const str_t *contact, const str_t *id,
 void add_tuple_info(presentity_info_t *p, presence_tuple_info_t *t);
 void free_presentity_info(presentity_info_t *p);
 
-list_presence_info_t *create_list_presence_info(const str_t *uri);
-void free_list_presence_info(list_presence_info_t *p);
+raw_presence_info_t *create_raw_presence_info(const str_t *uri);
+void free_raw_presence_info(raw_presence_info_t *p);
 
 presence_note_t *create_presence_note(const str_t *note, const str_t *lang);
 presence_note_t *create_presence_note_zt(const char *note, const char *lang);

+ 1 - 1
scripts/dbtext/ser_db/rls_subscription

@@ -1 +1 @@
-id(str) doc_version(int) dialog(str) expires(int) status(int) contact(str) uri(str) package(str) w_uri(str) 
+id(str) doc_version(int) dialog(str) expires(int) status(int) contact(str) uri(str) package(str) w_uri(str) xcap_root(str) 

+ 1 - 0
scripts/mysql/my_create.sql

@@ -413,6 +413,7 @@ CREATE TABLE rls_subscription (
     uri VARCHAR(255) NOT NULL,
     package VARCHAR(128) NOT NULL,
     w_uri VARCHAR(255) NOT NULL,
+    xcap_root VARCHAR(255) NOT NULL,
     UNIQUE KEY rls_subscription_key (id)
 );
 

+ 1 - 0
scripts/oracle/or_create.sql

@@ -396,6 +396,7 @@ CREATE TABLE rls_subscription (
     uri string(255) NOT NULL,
     package string(128) NOT NULL,
     w_uri string(255) NOT NULL,
+    xcap_root string(255) NOT NULL,
     rls_subscription_key UNIQUE (id, )
 );
 

+ 1 - 0
scripts/postgres/pg_create.sql

@@ -430,6 +430,7 @@ CREATE TABLE rls_subscription (
     uri VARCHAR(255) NOT NULL,
     package VARCHAR(128) NOT NULL,
     w_uri VARCHAR(255) NOT NULL,
+    xcap_root VARCHAR(255) NOT NULL,
     CONSTRAINT rls_subscription_key UNIQUE (id)
 );