All pastes #17428 Raw Edit

Something

public text v1 · immutable
#17428 ·published 2005-07-11 05:18 UTC
rendered paste body
static int restart_monitor(void)
{
	pthread_attr_t attr;
	/* 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;
	}
	if (monitor_thread == pthread_self()) {
		ast_mutex_unlock(&monlock);
		ast_log(LOG_WARNING, "Cannot kill myself\n");
		return -1;
	}
	if (monitor_thread != AST_PTHREADT_NULL) {
+#ifndef __CYGWIN__
		/* Wake up the thread */
		pthread_kill(monitor_thread, SIGURG);
	} else {
+#else		
+		pthread_cancel(monitor_thread);
+		pthread_join(monitor_thread, NULL);
+	}
+#endif   
		pthread_attr_init(&attr);
		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
		/* Start a new monitor */
		if (ast_pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
			ast_mutex_unlock(&monlock);
			ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
			return -1;
		}
+#ifndef __CYGWIN__
 	}
+#endif   
	ast_mutex_unlock(&monlock);
	return 0;
}