chan_lcr: fixed typo, that made rebuffer-mode request a parameter,
[lcr.git] / chan_lcr.c
index 5a5b6f9..906e6a3 100644 (file)
@@ -295,6 +295,7 @@ struct chan_call *alloc_call(void)
                free_call(*callp);
                return(NULL);
        }
+       fcntl((*callp)->pipe[0], F_SETFL, O_NONBLOCK);
        CDEBUG(*callp, NULL, "Call instance allocated.\n");
        return(*callp);
 }
@@ -476,7 +477,7 @@ void apply_opt(struct chan_call *call, char *data)
                                bchannel_pipeline(call->bchannel, call->pipeline);
                        break;
                case 'r':
-                       if (opt[1] == '\0') {
+                       if (opt[1] != '\0') {
                                CERROR(call, call->ast, "Option 'r' (re-buffer 160 bytes) expects no parameter.\n", opt);
                                break;
                        }
@@ -746,10 +747,10 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c
        }
        call->pbx_started = 1;
 //     if (call->state == CHAN_LCR_STATE_IN_DIALING)
-//             ast_setstate(ast, AST_STATE_DIALING);
+               ast_setstate(ast, AST_STATE_RINGING);
 //     else
-//             ast_setstate(ast, AST_STATE_OFFHOOK);
-       return;
+//             ast_setstate(ast, AST_STATE_RINGING);
+//     return;
 }
 
 /*
@@ -1964,9 +1965,14 @@ static struct ast_frame *lcr_read(struct ast_channel *ast)
                } else {
                        len = read(call->pipe[0], call->read_buff, sizeof(call->read_buff));
                }
+               if (len < 0 && errno == EAGAIN) {
+                       ast_mutex_unlock(&chan_lock);
+                       return &ast_null_frame;
+               }
                if (len <= 0) {
                        close(call->pipe[0]);
                        call->pipe[0] = -1;
+                       ast_mutex_unlock(&chan_lock);
                        return NULL;
                }
        }