[asterisk-commits] qwell: trunk r43519 - in /trunk: ./ channels/chan_skinny.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Sep 22 15:13:47 MST 2006


Author: qwell
Date: Fri Sep 22 17:13:47 2006
New Revision: 43519

URL: http://svn.digium.com/view/asterisk?rev=43519&view=rev
Log:
Merged revisions 43518 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r43518 | qwell | 2006-09-22 15:12:12 -0700 (Fri, 22 Sep 2006) | 4 lines

Allow chan_skinny.so to be unloaded properly.

Remove reload support, since it doesn't actually...work.

........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_skinny.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-1.4-merged (original)
+++ branch-1.4-merged Fri Sep 22 17:13:47 2006
@@ -1,1 +1,1 @@
-/branches/1.4:1-43376,43383,43386,43388,43392,43396,43405,43410,43422,43441,43445,43450,43454,43456,43464,43466,43469,43477,43482,43486,43489,43492
+/branches/1.4:1-43376,43383,43386,43388,43392,43396,43405,43410,43422,43441,43445,43450,43454,43456,43464,43466,43469,43477,43482,43486,43489,43492,43518

Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?rev=43519&r1=43518&r2=43519&view=diff
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Fri Sep 22 17:13:47 2006
@@ -4234,10 +4234,8 @@
 	/* If we're supposed to be stopped -- stay stopped */
 	if (monitor_thread == AST_PTHREADT_STOP)
 		return 0;
-	if (ast_mutex_lock(&monlock)) {
-		ast_log(LOG_WARNING, "Unable to lock monitor\n");
-		return -1;
-	}
+
+	ast_mutex_lock(&monlock);
 	if (monitor_thread == pthread_self()) {
 		ast_mutex_unlock(&monlock);
 		ast_log(LOG_WARNING, "Cannot kill myself\n");
@@ -4476,6 +4474,11 @@
 	ast_mutex_unlock(&devicelock);
 }
 
+#if 0
+/*
+ * XXX This never worked properly anyways.
+ * Let's get rid of it, until we can fix it.
+ */
 static int reload(void)
 {
 	delete_devices();
@@ -4483,6 +4486,7 @@
 	restart_monitor();
 	return 0;
 }
+#endif
 
 static int load_module(void)
 {
@@ -4521,6 +4525,39 @@
 
 static int unload_module(void)
 {
+	struct skinnysession *s, *slast;
+	struct skinny_device *d;
+	struct skinny_line *l;
+	struct skinny_subchannel *sub;
+
+	ast_mutex_lock(&sessionlock);
+	/* Destroy all the interfaces and free their memory */
+	s = sessions;
+	while(s) {
+		slast = s;
+		s = s->next;
+		for (d = slast->device; d; d = d->next) {
+			for (l = d->lines; l; l = l->next) {
+				ast_mutex_lock(&l->lock);
+				for (sub = l->sub; sub; sub = sub->next) {
+					ast_mutex_lock(&sub->lock);
+					if (sub->owner) {
+						sub->alreadygone = 1;
+						ast_softhangup(sub->owner, AST_SOFTHANGUP_APPUNLOAD);
+					}
+					ast_mutex_unlock(&sub->lock);
+				}
+				ast_mutex_unlock(&l->lock);
+			}
+		}
+		if (slast->fd > -1)
+			close(slast->fd);
+		ast_mutex_destroy(&slast->lock);
+		free(slast);
+	}
+	sessions = NULL;
+	ast_mutex_unlock(&sessionlock);
+
 	delete_devices();
 
 	ast_mutex_lock(&monlock);
@@ -4532,20 +4569,21 @@
 	monitor_thread = AST_PTHREADT_STOP;
 	ast_mutex_unlock(&monlock);
 
-#if 0 /* XXX This is...funky.  Will fix shortly */
-	ast_mutex_lock(&sessionlock);
-	/* Destroy all the interfaces and free their memory */
-	p = iflist;
-	while(p) {
-		pl = p;
-		p = p->next;
-		/* Free associated memory */
-		ast_mutex_destroy(&pl->lock);
-		free(pl);
-	}
-	iflist = NULL;
-	ast_mutex_unlock(&sessionlock);
-#endif
+	if (tcp_thread && (tcp_thread != AST_PTHREADT_STOP)) {
+		pthread_cancel(tcp_thread);
+		pthread_kill(tcp_thread, SIGURG);
+		pthread_join(tcp_thread, NULL);
+	}
+	tcp_thread = AST_PTHREADT_STOP;
+
+	ast_mutex_lock(&netlock);
+	if (accept_t && (accept_t != AST_PTHREADT_STOP)) {
+		pthread_cancel(accept_t);
+		pthread_kill(accept_t, SIGURG);
+		pthread_join(accept_t, NULL);
+	}
+	accept_t = AST_PTHREADT_STOP;
+	ast_mutex_unlock(&netlock);
 
 	ast_rtp_proto_unregister(&skinny_rtp);
 	ast_channel_unregister(&skinny_tech);
@@ -4560,5 +4598,4 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Skinny Client Control Protocol (Skinny)",
 		.load = load_module,
 		.unload = unload_module,
-		.reload = reload,
 	       );



More information about the asterisk-commits mailing list