aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_modem.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels/chan_modem.c')
-rwxr-xr-xchannels/chan_modem.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/channels/chan_modem.c b/channels/chan_modem.c
index c2f3bf0f9..50a63bb75 100755
--- a/channels/chan_modem.c
+++ b/channels/chan_modem.c
@@ -509,6 +509,18 @@ static int modem_write(struct ast_channel *ast, struct ast_frame *frame)
return res;
}
+static int modem_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
+{
+ struct ast_modem_pvt *p = newchan->pvt->pvt;
+ast_log(LOG_WARNING, "fixup called\n");
+ if (p->owner!=oldchan) {
+ ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n",oldchan,p->owner);
+ return -1;
+ }
+ p->owner = newchan;
+ return 0;
+}
+
struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state)
{
struct ast_channel *tmp;
@@ -528,6 +540,7 @@ struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state)
tmp->pvt->answer = modem_answer;
tmp->pvt->read = modem_read;
tmp->pvt->write = modem_write;
+ tmp->pvt->fixup = modem_fixup;
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
if (strlen(i->cid))
tmp->callerid = strdup(i->cid);
@@ -707,8 +720,8 @@ static struct ast_modem_pvt *mkif(char *iface)
#endif
tmp = malloc(sizeof(struct ast_modem_pvt));
- memset(tmp, 0, sizeof(struct ast_modem_pvt));
if (tmp) {
+ memset(tmp, 0, sizeof(struct ast_modem_pvt));
tmp->fd = open(iface, O_RDWR | O_NONBLOCK);
if (tmp->fd < 0) {
ast_log(LOG_WARNING, "Unable to open '%s'\n", iface);