]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Tue Feb 3 10:31:33 CST 2009 Pekka Pessi <first.last@nokia.com>
authorBrian West <brian@freeswitch.org>
Thu, 26 Feb 2009 18:24:05 +0000 (18:24 +0000)
committerBrian West <brian@freeswitch.org>
Thu, 26 Feb 2009 18:24:05 +0000 (18:24 +0000)
  * su_wait.h: added su_root_clone()

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12299 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/sofia-sip/.update
libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h
libs/sofia-sip/libsofia-sip-ua/su/su_root.c

index 3bf2c4c1d0da30822af4b1e92a6f448dd3416c21..46eeb2177e89cf0334701d4ce5ce62f3e788a22f 100644 (file)
@@ -1 +1 @@
-Thu Feb 26 12:22:23 CST 2009
+Thu Feb 26 12:23:25 CST 2009
index 8584ea3e62be8b496a799dc70486c5f9f9d35811..ad67723bb46ff979f2ff89734fa3ff17bf94da25 100644 (file)
@@ -487,6 +487,9 @@ SOFIAPUBFUN int su_root_has_thread(su_root_t *root);
 SOFIAPUBFUN int su_root_set_max_defer(su_root_t *, su_duration_t max_defer);
 SOFIAPUBFUN su_duration_t su_root_get_max_defer(su_root_t const *self);
 
+SOFIAPUBFUN su_root_t *su_root_clone(su_root_t *root, su_root_magic_t *magic)
+  __attribute__((__malloc__));
+
 /* Timers */
 SOFIAPUBFUN su_timer_t *su_timer_create(su_task_r const, su_duration_t msec)
      __attribute__((__malloc__));
index 128dd8be0635598358c5460f44ab1cadd9d701bc..e2179714e0935b4f25e5d850cef7a35cd31a3e14 100644 (file)
@@ -409,6 +409,48 @@ su_root_t *su_root_create(su_root_magic_t *magic)
   return su_root_create_with_port(magic, su_port_create());
 }
 
+/* Initializer used by su_root_clone() */
+static int
+su_root_clone_initializer(su_root_t *root,
+                         su_root_magic_t *magic)
+{
+  *(su_root_t **)magic = root;
+  return 0;
+}
+
+/** Create a a new root object sharing port/thread with existing one.
+ *
+ * Allocate and initialize the instance of su_root_t.
+ *
+ * @param magic     pointer to user data
+ *
+ * @return A pointer to allocated su_root_t instance, NULL on error.
+ *
+ * @NEW_1_12_11
+ */
+su_root_t *
+su_root_clone(su_root_t *self, su_root_magic_t *magic)
+{
+  int threading = 0, error;
+  su_clone_r clone;
+  su_root_t *cloned = NULL;
+
+  if (self == NULL)
+    return NULL;
+
+  threading = self->sur_threading, self->sur_threading = 0;
+  error = su_clone_start(self, clone,
+                        (void *)&cloned, su_root_clone_initializer, NULL);
+  self->sur_threading = threading;
+
+  if (error)
+    return NULL;
+
+  su_clone_forget(clone);      /* destroyed with su_root_destroy() */
+  su_root_set_magic(cloned, magic);
+  return cloned;
+}
+
 /**@internal
  *
  * Create a reactor object using given message port.