Fix chan_modem_i4l to be sure we use unsigned (bug #3412)
[asterisk/asterisk.git] / autoservice.c
index 2f28f35..df4973a 100755 (executable)
@@ -13,7 +13,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <pthread.h>
 #include <string.h>
 #include <sys/time.h>
 #include <signal.h>
@@ -33,6 +32,8 @@
 #include <asterisk/chanvars.h>
 #include <asterisk/linkedlists.h>
 #include <asterisk/indications.h>
+#include <asterisk/lock.h>
+#include <asterisk/utils.h>
 
 #define MAX_AUTOMONS 256
 
@@ -106,7 +107,7 @@ int ast_autoservice_start(struct ast_channel *chan)
                        aslist = as;
                        res = 0;
                        if (needstart) {
-                               if (pthread_create(&asthread, NULL, autoservice_run, NULL)) {
+                               if (ast_pthread_create(&asthread, NULL, autoservice_run, NULL)) {
                                        ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
                                        free(aslist);
                                        aslist = NULL;
@@ -146,7 +147,7 @@ int ast_autoservice_stop(struct ast_channel *chan)
                pthread_kill(asthread, SIGURG);
        ast_mutex_unlock(&autolock);
        /* Wait for it to un-block */
-       while(chan->blocking)
+       while(ast_test_flag(chan, AST_FLAG_BLOCKING))
                usleep(1000);
        return res;
 }