More BSD enhancements
[asterisk/asterisk.git] / channels / chan_phone.c
index b8ce778..80232c3 100755 (executable)
@@ -146,18 +146,18 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
 
        PHONE_CID cid;
        time_t UtcTime;
-       struct tm *t;
+       struct tm tm;
 
 
        if (ast->callerid) {
                time(&UtcTime);
-               t = localtime(&UtcTime);
+               localtime_r(&UtcTime,&tm);
 
-               if(t != NULL) {
-                       sprintf(cid.month, "%02d",(t->tm_mon + 1));
-                       sprintf(cid.day, "%02d", t->tm_mday);
-                       sprintf(cid.hour, "%02d", t->tm_hour);
-                       sprintf(cid.min, "%02d", t->tm_min);
+               if(&tm != NULL) {
+                       sprintf(cid.month, "%02d",(tm.tm_mon + 1));
+                       sprintf(cid.day, "%02d", tm.tm_mday);
+                       sprintf(cid.hour, "%02d", tm.tm_hour);
+                       sprintf(cid.min, "%02d", tm.tm_min);
                }
                strcpy(cid.name, "Unknown");
                sprintf(cid.number,"%s",ast->callerid);
@@ -586,7 +586,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
                        res = phone_write_buf(p, pos, expected, maxfr);
                }
                if (res != expected) {
-                       if (errno != EAGAIN) {
+                       if ((errno != EAGAIN) && (errno != EINTR)) {
                                if (res < 0) 
                                        ast_log(LOG_WARNING, "Write returned error (%s)\n", strerror(errno));
        /*
@@ -848,9 +848,9 @@ static void *do_monitor(void *data)
                                tv.tv_usec = 30000;
                                tv.tv_sec = 0;
                        }
-                       res = select(n + 1, &rfds, NULL, &efds, &tv);
+                       res = ast_select(n + 1, &rfds, NULL, &efds, &tv);
                } else {
-                       res = select(n + 1, &rfds, NULL, &efds, NULL);
+                       res = ast_select(n + 1, &rfds, NULL, &efds, NULL);
                        tv.tv_usec = 0;
                        tv.tv_sec = 0;
                        tonepos = 0;