[svn-commits] mattf: branch 1.2 r2398 - /branches/1.2/zaptel-base.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Sat Apr 7 09:49:47 MST 2007
Author: mattf
Date: Sat Apr 7 11:49:46 2007
New Revision: 2398
URL: http://svn.digium.com/view/zaptel?view=rev&rev=2398
Log:
Fix for #9208. Thanks adomo and Tzafrir!
Modified:
branches/1.2/zaptel-base.c
Modified: branches/1.2/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/zaptel-base.c?view=diff&rev=2398&r1=2397&r2=2398
==============================================================================
--- branches/1.2/zaptel-base.c (original)
+++ branches/1.2/zaptel-base.c Sat Apr 7 11:49:46 2007
@@ -748,16 +748,19 @@
if (!signal_pending(current)) schedule();
current->state = TASK_RUNNING;
remove_wait_queue(q, &wait);
- if (signal_pending(current)) return -ERESTARTSYS;
+ if (signal_pending(current)) {
+ printk(KERN_WARNING "zaptel.c:%d (pid %d: %s) got signal %08lX\n", __LINE__, current->pid, current->comm, current->pending.signal.sig[0]);
+ return -ERESTARTSYS;
+ }
return(0);
}
-static inline void calc_fcs(struct zt_chan *ss)
+static inline void calc_fcs(struct zt_chan *ss, int inwritebuf)
{
int x;
unsigned int fcs=PPP_INITFCS;
- unsigned char *data = ss->writebuf[ss->inwritebuf];
- int len = ss->writen[ss->inwritebuf];
+ unsigned char *data = ss->writebuf[inwritebuf];
+ int len = ss->writen[inwritebuf];
/* Not enough space to do FCS calculation */
if (len < 2)
return;
@@ -1692,8 +1695,8 @@
}
amnt = count;
if (chan->flags & ZT_FLAG_LINEAR) {
- if (amnt > (chan->readn[chan->outreadbuf] << 1))
- amnt = chan->readn[chan->outreadbuf] << 1;
+ if (amnt > (chan->readn[res] << 1))
+ amnt = chan->readn[res] << 1;
if (amnt) {
/* There seems to be a max stack size, so we have
to do this in smaller pieces */
@@ -1706,7 +1709,7 @@
if (pass > 128)
pass = 128;
for (x=0;x<pass;x++)
- lindata[x] = ZT_XLAW(chan->readbuf[chan->outreadbuf][x + pos], chan);
+ lindata[x] = ZT_XLAW(chan->readbuf[res][x + pos], chan);
if (copy_to_user(usrbuf + (pos << 1), lindata, pass << 1))
return -EFAULT;
left -= pass;
@@ -1714,18 +1717,18 @@
}
}
} else {
- if (amnt > chan->readn[chan->outreadbuf])
- amnt = chan->readn[chan->outreadbuf];
+ if (amnt > chan->readn[res])
+ amnt = chan->readn[res];
if (amnt) {
- if (copy_to_user(usrbuf, chan->readbuf[chan->outreadbuf], amnt))
+ if (copy_to_user(usrbuf, chan->readbuf[res], amnt))
return -EFAULT;
}
}
spin_lock_irqsave(&chan->lock, flags);
- chan->readidx[chan->outreadbuf] = 0;
- chan->readn[chan->outreadbuf] = 0;
- oldbuf = chan->outreadbuf;
- chan->outreadbuf = (chan->outreadbuf + 1) % chan->numbufs;
+ chan->readidx[res] = 0;
+ chan->readn[res] = 0;
+ oldbuf = res;
+ res = (chan->outreadbuf + 1) % chan->numbufs;
if (chan->outreadbuf == chan->inreadbuf) {
/* Out of stuff */
chan->outreadbuf = -1;
@@ -1807,21 +1810,21 @@
return -EFAULT;
left -= pass;
for (x=0;x<pass;x++)
- chan->writebuf[chan->inwritebuf][x + pos] = ZT_LIN2X(lindata[x], chan);
+ chan->writebuf[res][x + pos] = ZT_LIN2X(lindata[x], chan);
pos += pass;
}
- chan->writen[chan->inwritebuf] = amnt >> 1;
+ chan->writen[res] = amnt >> 1;
} else {
- if (copy_from_user(chan->writebuf[chan->inwritebuf], usrbuf, amnt))
+ if (copy_from_user(chan->writebuf[res], usrbuf, amnt))
return -EFAULT;
- chan->writen[chan->inwritebuf] = amnt;
- }
- chan->writeidx[chan->inwritebuf] = 0;
+ chan->writen[res] = amnt;
+ }
+ chan->writeidx[res] = 0;
if (chan->flags & ZT_FLAG_FCS)
- calc_fcs(chan);
- oldbuf = chan->inwritebuf;
+ calc_fcs(chan, res);
+ oldbuf = res;
spin_lock_irqsave(&chan->lock, flags);
- chan->inwritebuf = (chan->inwritebuf + 1) % chan->numbufs;
+ chan->inwritebuf = (res + 1) % chan->numbufs;
if (chan->inwritebuf == chan->outwritebuf) {
/* Don't stomp on the transmitter, just wait for them to
wake us up */
More information about the svn-commits
mailing list