X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=chan_lcr.c;h=52c2a3121a13762fb30ee200ff7d2463258e5bed;hp=5a5b6f953ea9c41802ed422b13b4fb01fdac9c90;hb=08aad9a8c5ad279759e0a870b1dd0d8159ce3444;hpb=ff4d197d5ecb2cb29a55f78b260ab387e3afc80d diff --git a/chan_lcr.c b/chan_lcr.c index 5a5b6f9..52c2a31 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); } @@ -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; } /* @@ -1427,7 +1428,6 @@ int handle_socket(void) int open_socket(void) { int ret; - char *socket_name = SOCKET_NAME; int conn; struct sockaddr_un sock_address; unsigned int on = 1; @@ -1443,7 +1443,7 @@ int open_socket(void) /* set socket address and name */ memset(&sock_address, 0, sizeof(sock_address)); sock_address.sun_family = PF_UNIX; - strcpy(sock_address.sun_path, socket_name); + sprintf(sock_address.sun_path, SOCKET_NAME, options.lock); /* connect socket */ if ((conn = connect(lcr_sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0) @@ -1964,9 +1964,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; } } @@ -2090,21 +2095,25 @@ static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz /* * fixup asterisk */ -static int lcr_fixup(struct ast_channel *oldast, struct ast_channel *newast) +static int lcr_fixup(struct ast_channel *oldast, struct ast_channel *ast) { struct chan_call *call; + if (!ast) { + return -1; + } + ast_mutex_lock(&chan_lock); - call = oldast->tech_pvt; + call = ast->tech_pvt; if (!call) { - CERROR(NULL, oldast, "Received fixup from Asterisk, but no call instance exists.\n"); + CERROR(NULL, ast, "Received fixup from Asterisk, but no call instance exists.\n"); ast_mutex_unlock(&chan_lock); return -1; } - CDEBUG(call, oldast, "Received fixup from Asterisk.\n"); - call->ast = newast; - ast_mutex_lock(&chan_lock); + CDEBUG(call, ast, "Received fixup from Asterisk.\n"); + call->ast = ast; + ast_mutex_unlock(&chan_lock); return 0; }