[asterisk-commits] irroot: branch irroot/asterisk-trunk-quack-queue r342984 - /team/irroot/aster...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 2 02:17:06 CDT 2011


Author: irroot
Date: Wed Nov  2 02:17:03 2011
New Revision: 342984

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342984
Log:
Do not use memcpy to duplicate state for devstate

Modified:
    team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c

Modified: team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c?view=diff&rev=342984&r1=342983&r2=342984
==============================================================================
--- team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c (original)
+++ team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c Wed Nov  2 02:17:03 2011
@@ -1530,7 +1530,7 @@
 
 static int set_device_status(const char *device, int status)
 {
-	struct mem_state *s, *tmp;
+	struct mem_state *s;
 
 	if (!(s = ao2_find(devices, device, OBJ_KEY))) {
 		return -1;
@@ -1539,15 +1539,14 @@
 	ao2_lock(s);
 	if (s->status != status) {
 		s->status = status;
-		if ((tmp = ao2_alloc(sizeof(*tmp), NULL))) {
-			memcpy(tmp, s, sizeof(*tmp));
-			if (ast_taskprocessor_push(devicestate_tps, update_status, tmp)) {
-				ao2_ref(tmp, -1);
-			}
-		}
-	}
-	ao2_unlock(s);
-	ao2_ref(s, -1);
+		ao2_unlock(s);
+		if (ast_taskprocessor_push(devicestate_tps, update_status, s)) {
+			ao2_ref(s, -1);
+		}
+	} else {
+		ao2_unlock(s);
+		ao2_ref(s, -1);
+	}
 
 	return 0;
 }
@@ -1682,7 +1681,9 @@
 {
 	int status;
 	struct mem_state *s;
-	struct mem_state *tmp;
+
+	ao2_lock(m);
+	s = m->device;
 
 	if (!strncasecmp(s->state_interface, "hint:", 5)) {
 		char *context = ast_strdupa(s->state_interface);
@@ -1692,19 +1693,17 @@
 		status = ast_device_state(s->state_interface);
 	}
 
-	ao2_lock(m);
-	s = m->device;
 	ao2_lock(s);
 	if (s->status != status) {
 		s->status = status;
-		if ((tmp = ao2_alloc(sizeof(*tmp), NULL))) {
-			memcpy(tmp, s, sizeof(*tmp));
-			if (ast_taskprocessor_push(devicestate_tps, update_status, tmp)) {
-				ao2_ref(tmp, -1);
-			}
-		}
-	}
-	ao2_unlock(s);
+		ao2_unlock(s);
+		if (ast_taskprocessor_push(devicestate_tps, update_status, s)) {
+			ao2_ref(s, -1);
+		}
+	} else {
+		ao2_unlock(s);
+		ao2_ref(s, -1);
+	}
 	ao2_unlock(m);
 }
 




More information about the asterisk-commits mailing list