[svn-commits] file: branch file/pjsip-outbound-publish r419752 - /team/file/pjsip-outbound-...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jul 29 05:16:15 CDT 2014


Author: file
Date: Tue Jul 29 05:13:05 2014
New Revision: 419752

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419752
Log:
Incorporate feedback.

Modified:
    team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c
    team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c
    team/file/pjsip-outbound-publish/res/res_pjsip_pubsub.c

Modified: team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c?view=diff&rev=419752&r1=419751&r2=419752
==============================================================================
--- team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c (original)
+++ team/file/pjsip-outbound-publish/res/res_pjsip_outbound_publish.c Tue Jul 29 05:13:05 2014
@@ -611,24 +611,59 @@
 
 static int datastore_hash(const void *obj, int flags)
 {
-	const struct ast_datastore *datastore = obj;
-	const char *uid = flags & OBJ_KEY ? obj : datastore->uid;
-
-	ast_assert(uid != NULL);
+	const struct ast_datastore *datastore;
+	const char *uid;
+
+	switch (flags & OBJ_SEARCH_MASK) {
+	case OBJ_SEARCH_KEY:
+		uid = obj;
+		break;
+	case OBJ_SEARCH_OBJECT:
+		datastore = obj;
+		uid = datastore->uid;
+		break;
+	default:
+		/* Hash can only work on something with a full key. */
+		ast_assert(0);
+		return 0;
+	}
 
 	return ast_str_hash(uid);
 }
 
 static int datastore_cmp(void *obj, void *arg, int flags)
 {
-	const struct ast_datastore *datastore1 = obj;
-	const struct ast_datastore *datastore2 = arg;
-	const char *uid2 = flags & OBJ_KEY ? arg : datastore2->uid;
-
-	ast_assert(datastore1->uid != NULL);
-	ast_assert(uid2 != NULL);
-
-	return strcmp(datastore1->uid, uid2) ? 0 : CMP_MATCH | CMP_STOP;
+	const struct ast_datastore *object_left = obj;
+	const struct ast_datastore *object_right = arg;
+	const char *right_key = arg;
+	int cmp;
+
+	switch (flags & OBJ_SEARCH_MASK) {
+	case OBJ_SEARCH_OBJECT:
+		right_key = object_right->uid;
+		/* Fall through */
+	case OBJ_SEARCH_KEY:
+		cmp = strcmp(object_left->uid, right_key);
+		break;
+	case OBJ_SEARCH_PARTIAL_KEY:
+        cmp = strncmp(object_left->uid, right_key, strlen(right_key));
+		break;
+	default:
+		/*
+		 * What arg points to is specific to this traversal callback
+		 * and has no special meaning to astobj2.
+		 */
+		cmp = 0;
+		break;
+	}
+	if (cmp) {
+		return 0;
+	}
+	/*
+	 * At this point the traversal callback is identical to a sorted
+	 * container.
+	 */
+	return CMP_MATCH;
 }
 
 /*! \brief Allocator function for publish client state */

Modified: team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c?view=diff&rev=419752&r1=419751&r2=419752
==============================================================================
--- team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c (original)
+++ team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c Tue Jul 29 05:13:05 2014
@@ -424,10 +424,6 @@
 	return 200;
 }
 
-static void asterisk_publication_expire(struct ast_sip_publication *pub)
-{
-}
-
 static int asterisk_publication_devicestate(struct ast_sip_publication *pub, struct asterisk_publication_config *config,
 	struct ast_eid *pubsub_eid, struct ast_json *json)
 {
@@ -657,7 +653,6 @@
 struct ast_sip_publish_handler asterisk_publication_handler = {
 	.event_name = "asterisk",
 	.new_publication = asterisk_publication_new,
-	.publish_expire = asterisk_publication_expire,
 	.publication_state_change = asterisk_publication_state_change,
 };
 

Modified: team/file/pjsip-outbound-publish/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pjsip-outbound-publish/res/res_pjsip_pubsub.c?view=diff&rev=419752&r1=419751&r2=419752
==============================================================================
--- team/file/pjsip-outbound-publish/res/res_pjsip_pubsub.c (original)
+++ team/file/pjsip-outbound-publish/res/res_pjsip_pubsub.c Tue Jul 29 05:13:05 2014
@@ -351,7 +351,7 @@
 struct ast_sip_publication_resource {
 	/*! \brief Sorcery object details */
 	SORCERY_OBJECT(details);
-	/*! \brief Optional endpoint that this publication will only accept messages from */
+	/*! \brief Optional name of an endpoint that is only allowed to publish to this resource */
 	char *endpoint;
 	/*! \brief Mapping for event types to configuration */
 	struct ast_variable *events;
@@ -1647,7 +1647,9 @@
 {
 	RAII_VAR(struct ast_sip_publication *, publication, data, ao2_cleanup);
 
-	publication->handler->publish_expire(publication);
+	if (publication->handler->publish_expire) {
+		publication->handler->publish_expire(publication);
+	}
 
 	return 0;
 }




More information about the svn-commits mailing list