Index: include/asterisk/module.h
===================================================================
--- include/asterisk/module.h	(revision 347528)
+++ include/asterisk/module.h	(working copy)
@@ -205,6 +205,7 @@
 	AST_MODPRI_REALTIME_DEPEND =    10,  /*!< Dependency for a realtime driver */
 	AST_MODPRI_REALTIME_DEPEND2 =   20,  /*!< Second level dependency for a realtime driver (func_curl needs res_curl, but is needed by res_config_curl) */
 	AST_MODPRI_REALTIME_DRIVER =    30,  /*!< A realtime driver, which provides configuration services for other modules */
+	AST_MODPRI_TIMING =             40,  /*!< Dependency for a channel (MOH needs timing interfaces to be fully loaded) */
 	AST_MODPRI_CHANNEL_DEPEND =     50,  /*!< Channel driver dependency (may depend upon realtime, e.g. MOH) */
 	AST_MODPRI_CHANNEL_DRIVER =     60,  /*!< Channel drivers (provide devicestate) */
 	AST_MODPRI_APP_DEPEND =         70,  /*!< Dependency for an application */
Index: res/res_timing_pthread.c
===================================================================
--- res/res_timing_pthread.c	(revision 347528)
+++ res/res_timing_pthread.c	(working copy)
@@ -525,5 +525,5 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "pthread Timing Interface",
 		.load = load_module,
 		.unload = unload_module,
-		.load_pri = AST_MODPRI_CHANNEL_DEPEND,
+		.load_pri = AST_MODPRI_TIMING,
 		);
Index: res/res_timing_dahdi.c
===================================================================
--- res/res_timing_dahdi.c	(revision 347528)
+++ res/res_timing_dahdi.c	(working copy)
@@ -203,5 +203,5 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "DAHDI Timing Interface",
 		.load = load_module,
 		.unload = unload_module,
-		.load_pri = AST_MODPRI_CHANNEL_DEPEND,
+		.load_pri = AST_MODPRI_TIMING,
 		);
Index: res/res_timing_timerfd.c
===================================================================
--- res/res_timing_timerfd.c	(revision 347528)
+++ res/res_timing_timerfd.c	(working copy)
@@ -337,5 +337,5 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Timerfd Timing Interface",
 		.load = load_module,
 		.unload = unload_module,
-		.load_pri = AST_MODPRI_CHANNEL_DEPEND,
+		.load_pri = AST_MODPRI_TIMING,
 		);
Index: res/res_musiconhold.c
===================================================================
--- res/res_musiconhold.c	(revision 347528)
+++ res/res_musiconhold.c	(working copy)
@@ -673,7 +673,7 @@
 			}
 		}
 		if (class->timer) {
-			struct pollfd pfd = { .fd = ast_timer_fd(class->timer), .events = POLLIN, };
+			struct pollfd pfd = { .fd = ast_timer_fd(class->timer), .events = POLLIN | POLLPRI, };
 
 #ifdef SOLARIS
 			thr_yield();
@@ -683,7 +683,7 @@
 				ast_timer_ack(class->timer, 1);
 				res = 320;
 			} else {
-				ast_log(LOG_ERROR, "poll() failed: %s\n", strerror(errno));
+				ast_log(LOG_WARNING, "poll() failed: %s\n", strerror(errno));
 				res = 0;
 			}
 			pthread_testcancel();
@@ -1222,6 +1222,7 @@
 
 	if (!(class->timer = ast_timer_open())) {
 		ast_log(LOG_WARNING, "Unable to create timer: %s\n", strerror(errno));
+		return -1;
 	}
 	if (class->timer && ast_timer_set_rate(class->timer, 25)) {
 		ast_log(LOG_WARNING, "Unable to set 40ms frame rate: %s\n", strerror(errno));
@@ -1249,7 +1250,9 @@
 {
 	struct mohclass *mohclass = NULL;
 
-	if ((mohclass = _get_mohbyname(moh->name, 0, MOH_NOTDELETED, file, line, funcname)) && !moh_diff(mohclass, moh)) {
+	mohclass = _get_mohbyname(moh->name, 0, MOH_NOTDELETED, file, line, funcname);
+
+	if (mohclass && !moh_diff(mohclass, moh)) {
 		ast_log(LOG_WARNING, "Music on Hold class '%s' already exists\n", moh->name);
 		mohclass = mohclass_unref(mohclass, "unreffing mohclass we just found by name");
 		if (unref) {
@@ -1588,6 +1591,12 @@
 
 	ast_debug(1, "Destroying MOH class '%s'\n", class->name);
 
+	ao2_lock(class);
+	while ((member = AST_LIST_REMOVE_HEAD(&class->members, list))) {
+		free(member);
+	}
+	ao2_unlock(class);
+
 	/* Kill the thread first, so it cannot restart the child process while the
 	 * class is being destroyed */
 	if (class->thread != AST_PTHREADT_NULL && class->thread != 0) {
@@ -1639,12 +1648,9 @@
 		ast_debug(1, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes);
 
 		close(class->srcfd);
+		class->srcfd = -1;
 	}
 
-	while ((member = AST_LIST_REMOVE_HEAD(&class->members, list))) {
-		free(member);
-	}
-
 	if (class->filearray) {
 		int i;
 		for (i = 0; i < class->total_files; i++) {
@@ -1663,6 +1669,7 @@
 	if (tid > 0) {
 		pthread_join(tid, NULL);
 	}
+
 }
 
 static int moh_class_mark(void *obj, void *arg, int flags)
