From a9c1ce57ba87ed4f83ce2ead103e9b6891e921c2 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Fri, 22 Aug 2008 20:08:43 +0200 Subject: [PATCH] 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) --- chan_lcr.c | 6 ++++++ 1 file changed, 6 insertions(+) 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; } } -- 2.13.6