[Asterisk-cvs] asterisk/channels chan_iax2.c,1.148,1.149
markster at lists.digium.com
markster at lists.digium.com
Mon Jun 7 14:46:14 CDT 2004
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv3977/channels
Modified Files:
chan_iax2.c
Log Message:
Simplify trunk transmission path and remove potential race (bug #1802)
Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- chan_iax2.c 4 Jun 2004 18:30:35 -0000 1.148
+++ chan_iax2.c 7 Jun 2004 19:48:53 -0000 1.149
@@ -267,7 +267,6 @@
struct iax2_trunk_peer *next;
int trunkerror;
int calls;
- int firstcallno;
} *tpeers = NULL;
static ast_mutex_t tpeerlock = AST_MUTEX_INITIALIZER;
@@ -1177,6 +1176,20 @@
return 0;
}
+static int transmit_trunk(struct iax_frame *f, struct sockaddr_in *sin)
+{
+ int res;
+ res = sendto(netsocket, f->data, f->datalen, 0,(struct sockaddr *)sin,
+ sizeof(*sin));
+ if (res < 0) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Received error: %s\n", strerror(errno));
+ handle_error();
+ } else
+ res = 0;
+ return res;
+}
+
static int send_packet(struct iax_frame *f)
{
int res;
@@ -2764,8 +2777,6 @@
/* Copy actual trunk data */
memcpy(ptr, f->data, f->datalen);
tpeer->trunkdatalen += f->datalen;
- if (!tpeer->firstcallno)
- tpeer->firstcallno = pvt->callno;
tpeer->calls++;
ast_mutex_unlock(&tpeer->lock);
}
@@ -4332,18 +4343,16 @@
fr->retrans = -1;
fr->transfer = 0;
/* Any appropriate call will do */
- fr->callno = tpeer->firstcallno;
fr->data = fr->afdata;
fr->datalen = tpeer->trunkdatalen + sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr);
#if 0
ast_log(LOG_DEBUG, "Trunking %d calls in %d bytes, ts=%d\n", calls, fr->datalen, ntohl(mth->ts));
#endif
- res = send_packet(fr);
+ res = transmit_trunk(fr, &tpeer->addr);
calls = tpeer->calls;
/* Reset transmit trunk side data */
tpeer->trunkdatalen = 0;
tpeer->calls = 0;
- tpeer->firstcallno = 0;
}
if (res < 0)
return res;
More information about the svn-commits
mailing list