summaryrefslogtreecommitdiffstats
path: root/chan_lcr.c
diff options
context:
space:
mode:
authorPeter Schlaile2008-08-22 20:08:43 +0200
committerroot2008-08-22 20:08:43 +0200
commita9c1ce57ba87ed4f83ce2ead103e9b6891e921c2 (patch)
tree24c7ab7da0ddbd39f24315bd9de38d8d04cdb505 /chan_lcr.c
parentremoved debug code from last commit (diff)
downloadlcr-a9c1ce57ba87ed4f83ce2ead103e9b6891e921c2.tar.gz
lcr-a9c1ce57ba87ed4f83ce2ead103e9b6891e921c2.tar.xz
lcr-a9c1ce57ba87ed4f83ce2ead103e9b6891e921c2.zip
chan_lcr: this fixes hanging with app_rxfax and a race condition
in lcr_read (lcr_read was hanging in locked-state forever, when no data was available, making any further calls impossible. Now we return a null-packet to asterisk) Sidenode: you have to use lcr_config(r) to receive faxes correctly. (app_rxfax seems to rely on 160-byte buffers)
Diffstat (limited to 'chan_lcr.c')
-rw-r--r--chan_lcr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/chan_lcr.c b/chan_lcr.c
index e09004c..de9d788 100644
--- a/chan_lcr.c
+++ b/chan_lcr.c
@@ -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);
}
@@ -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;
}
}