for(;;) {
ebuf = (char *)el_gets(el, &num);
+ if (!ebuf && write(1, "", 1) < 0)
+ break;
+
if (!ast_strlen_zero(ebuf)) {
if (ebuf[strlen(ebuf)-1] == '\n')
ebuf[strlen(ebuf)-1] = '\0';
for (;;) {
buf = (char *)el_gets(el, &num);
+
+ if (!buf && write(1, "", 1) < 0)
+ goto lostterm;
+
if (buf) {
if (buf[strlen(buf)-1] == '\n')
buf[strlen(buf)-1] = '\0';
monitor_sig_flags(NULL);
+lostterm:
return 0;
}
int ast_hangup(struct ast_channel *chan)
{
int res = 0;
+ struct ast_cdr *cdr = NULL;
/* Don't actually hang up a channel that will masquerade as someone else, or
if someone is going to masquerade as us */
chan->generator = NULL;
if (chan->cdr) { /* End the CDR if it hasn't already */
ast_cdr_end(chan->cdr);
- ast_cdr_detach(chan->cdr); /* Post and Free the CDR */
+ cdr = chan->cdr;
chan->cdr = NULL;
}
if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
ast_cause2str(chan->hangupcause)
);
ast_channel_free(chan);
+
+ /* Defer CDR processing until later */
+ if (cdr)
+ ast_cdr_detach(cdr);
+
return res;
}
pri = strsep(&stringp, ",");
if (!pri)
pri="";
+ pri = ast_skip_blanks(pri);
+ pri = ast_trim_blanks(pri);
label = strchr(pri, '(');
if (label) {
*label = '\0';