On Tuesday 10 August 2010, SourceForge.net wrote:
> I will commit my implementation. It is different from the one posted by
> Christophe as I have taken out the second lock completely.
> Unfortunately I still noticed some issues with it and I was not able to
> fix them until now. I am leaving in vacation until Monday and this is why I
> am putting it out now, as a proof of concept. I still need to fix a bug I
> saw in my test, and I will do that next week.

I have tesetd the new implementation and have a few comments and patches. I 
post them here, because SF doesn't allow me to attach patches to the ticket.


1) fix for a segfault in build_pending_publ.


2) Add queueing. In your implementation you only keep one extra publish. I'd 
prefer that the presence server receives all publishes, so i updated the patch 
from csollet to put them in a queue.


3) update_pua still needs to be rewritten to also queue publishes. Now it does 
nothing and thus the hash is never cleaned.

-- 
Greetings,

Alex Hermann

Index: opensips/modules/pua/hash.h
===================================================================
--- opensips.orig/modules/pua/hash.h	2010-08-13 18:04:50.000000000 +0200
+++ opensips/modules/pua/hash.h	2010-08-16 10:22:14.000000000 +0200
@@ -69,6 +69,7 @@
 	str body;
 	int expires;
 	void* cb_param;
+	struct publ* next;
 }publ_t;
 
 typedef struct ua_pres{
Index: opensips/modules/pua/send_publish.c
===================================================================
--- opensips.orig/modules/pua/send_publish.c	2010-08-13 18:04:50.000000000 +0200
+++ opensips/modules/pua/send_publish.c	2010-08-16 12:28:18.000000000 +0200
@@ -318,26 +318,28 @@
 		run_pua_callbacks(presentity, msg);
 		presentity->cb_param = NULL;
 	}
-	if(presentity->pending_publ)
+
+	presentity->waiting_reply = 0;
+	while(presentity->pending_publ)
 	{
+		LM_DBG("Found pending publish\n");
 		publ_t* pending_publ = presentity->pending_publ;
 		publ_info_t* publ = construct_pending_publ(presentity);
 		if(publ == NULL)
 		{
 			LM_ERR("Failed to create publish record\n");
-			lock_release(&HashT->p_records[hash_index].lock);
-			LM_DBG("Released hash lock %d\n", hash_index);
-			return;
+			presentity->pending_publ = pending_publ->next;
+			shm_free(pending_publ);
+			continue;
 		}
-		LM_DBG("Found pending publish\n");
-		presentity->pending_publ = 0;
+
+		presentity->waiting_reply = 1;
 		send_publish_int(presentity, publ, get_event(presentity->event),
 				presentity->hash_index);
 		pkg_free(publ);
+		presentity->pending_publ = pending_publ->next;
 		shm_free(pending_publ);
 	}
-	else
-		presentity->waiting_reply = 0;
 
 	lock_release(&HashT->p_records[hash_index].lock);
 	LM_DBG("Released hash lock %d\n", hash_index);
@@ -528,6 +530,7 @@
 	ua_pres_t pres;
 	unsigned int hash_index;
 	pua_event_t* ev= NULL;
+	publ_t **last;
 
 	LM_DBG("pres_uri=%.*s\n", publ->pres_uri->len, publ->pres_uri->s );
 
@@ -566,10 +569,12 @@
 	}
 	if(presentity && presentity->waiting_reply)
 	{
-		if(presentity->pending_publ)
-			shm_free(presentity->pending_publ);
-		presentity->pending_publ = build_pending_publ(publ);
-		if(presentity->pending_publ == NULL)
+		LM_DBG("Presentity is waiting for reply, queue this PUBLISH\n");
+		last = &presentity->pending_publ;
+		while (*last)
+			last = &((*last)->next);
+		*last = build_pending_publ(publ);
+		if(! *last)
 		{
 			LM_ERR("Failed to create pending publ record\n");
 			lock_release(&HashT->p_records[hash_index].lock);
Index: opensips/modules/pua/send_publish.c
===================================================================
--- opensips.orig/modules/pua/send_publish.c	2010-08-16 12:40:23.000000000 +0200
+++ opensips/modules/pua/send_publish.c	2010-08-16 12:40:39.000000000 +0200
@@ -348,7 +348,7 @@
 	publ_t* p;
 	int size;
 
-	size = sizeof(publ_t) + (publ->body)?publ->body->len:0+
+	size = sizeof(publ_t) + ((publ->body)?publ->body->len:0) + 
 		publ->content_type.len;
 	p = (publ_t*)shm_malloc(size);
 	if(p == NULL)
_______________________________________________
Devel mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

Reply via email to