Merged revisions 115313,121770,123272,139624,140205,144257 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

................
  r115313 | tilghman | 2008-05-05 15:22:08 -0500 (Mon, 05 May 2008) | 10 lines
  
  Merged revisions 115312 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r115312 | tilghman | 2008-05-05 15:17:55 -0500 (Mon, 05 May 2008) | 2 lines
  
  Reverse order, such that user configs override default selections
  
  ........
................
  r121770 | crichter | 2008-06-11 06:52:18 -0500 (Wed, 11 Jun 2008) | 9 lines
  
  Merged revisions 121751 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r121751 | crichter | 2008-06-11 11:28:04 +0200 (Mi, 11 Jun 2008) | 1 line
  
  fixed issue with previous commit, the find_free_channel test for channels which where inuse was broken.
  ........
................
  r123272 | russell | 2008-06-17 10:52:13 -0500 (Tue, 17 Jun 2008) | 12 lines
  
  Merged revisions 123271 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r123271 | russell | 2008-06-17 10:48:31 -0500 (Tue, 17 Jun 2008) | 4 lines
  
  Fix a memory leak in astobj2 that was pointed out by seanbright.  When a container
  got destroyed, the underlying bucket list entry for each object that was in the
  container at that time did not get free'd.
  
  ........
................
  r139624 | jpeeler | 2008-08-22 16:57:32 -0500 (Fri, 22 Aug 2008) | 13 lines
  
  Merged revisions 139621 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r139621 | jpeeler | 2008-08-22 16:36:13 -0500 (Fri, 22 Aug 2008) | 5 lines
  
  (closes issue #13359)
  Reported by: Laureano
  Patches:
        originate_channel_check.patch uploaded by Laureano (license 265)
  
  ........
................
  r140205 | jpeeler | 2008-08-26 13:48:55 -0500 (Tue, 26 Aug 2008) | 17 lines
  
  Merged revisions 140056 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r140056 | jpeeler | 2008-08-26 10:57:02 -0500 (Tue, 26 Aug 2008) | 9 lines
  
  (closes issue #12071)
  Reported by: tzafrir
  Patches:
        dahdi_close.diff uploaded by tzafrir (license 46)
  Tested by: tzafrir, jpeeler
  
  This patch fixes closing open file descriptors in the case of an error.
  
  
  ........
................
  r144257 | crichter | 2008-09-24 03:42:55 -0500 (Wed, 24 Sep 2008) | 9 lines
  
  Merged revisions 144238 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r144238 | crichter | 2008-09-24 10:20:52 +0200 (Mi, 24 Sep 2008) | 1 line
  
  improved helptext of misdn_set_opt.
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@160386 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2008-12-02 21:46:38 +00:00
parent 07d9e591ac
commit 3d50bd62b9
5 changed files with 95 additions and 105 deletions

View File

@@ -353,7 +353,7 @@ makeopts: configure
@exit 1
menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts
menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
menuselect/menuselect --check-deps menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
$(MOD_SUBDIRS_EMBED_LDSCRIPT):
@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
@@ -837,18 +837,8 @@ gmenuconfig: gmenuselect
nmenuconfig: nmenuselect
menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
@if [ -x menuselect/nmenuselect ]; then \
$(MAKE) nmenuselect; \
elif [ -x menuselect/cmenuselect ]; then \
$(MAKE) cmenuselect; \
elif [ -x menuselect/gmenuselect ]; then \
$(MAKE) gmenuselect; \
else \
echo "No menuselect user interface found. Install ncurses,"; \
echo "newt or GTK libraries to build one and re-rerun"; \
echo "'make menuselect'."; \
fi
menuselect: menuselect/menuselect menuselect-tree
-@menuselect/menuselect menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
cmenuselect: menuselect/cmenuselect menuselect-tree
-@menuselect/cmenuselect menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
@@ -896,6 +886,4 @@ pdf: asterisk.pdf
asterisk.pdf:
$(MAKE) -C doc/tex asterisk.pdf
.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) badshell installdirs _clean
FORCE:
.PHONY: menuselect menuselect.makeopts main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) badshell main/version.c include/asterisk/version.h installdirs

View File

@@ -1130,6 +1130,28 @@ static void dahdi_close(int fd)
close(fd);
}
static void dahdi_close_sub(struct dahdi_pvt *chan_pvt, int sub_num)
{
dahdi_close(chan_pvt->subs[sub_num].dfd);
chan_pvt->subs[sub_num].dfd = -1;
}
#ifdef HAVE_PRI
static void dahdi_close_pri_fd(struct dahdi_pri *pri, int fd_num)
{
dahdi_close(pri->fds[fd_num]);
pri->fds[fd_num] = -1;
}
#endif
#ifdef HAVE_SS7
static void dahdi_close_ss7_fd(struct dahdi_ss7 *ss7, int fd_num)
{
dahdi_close(ss7->fds[fd_num]);
ss7->fds[fd_num] = -1;
}
#endif
static int dahdi_setlinear(int dfd, int linear)
{
int res;
@@ -1169,7 +1191,7 @@ static int alloc_sub(struct dahdi_pvt *p, int x)
if (ioctl(p->subs[x].dfd, DAHDI_CHANNO, &p->subs[x].chan) == 1) {
ast_log(LOG_WARNING, "Unable to get channel number for pseudo channel on FD %d: %s\n", p->subs[x].dfd, strerror(errno));
dahdi_close(p->subs[x].dfd);
dahdi_close_sub(p, x);
p->subs[x].dfd = -1;
return -1;
}
@@ -1184,10 +1206,7 @@ static int unalloc_sub(struct dahdi_pvt *p, int x)
return -1;
}
ast_debug(1, "Released sub %d of channel %d\n", x, p->channel);
if (p->subs[x].dfd > -1) {
dahdi_close(p->subs[x].dfd);
}
p->subs[x].dfd = -1;
dahdi_close_sub(p, x);
p->subs[x].linear = 0;
p->subs[x].chan = 0;
p->subs[x].owner = NULL;
@@ -2771,6 +2790,7 @@ static void destroy_dahdi_pvt(struct dahdi_pvt **pvt)
if (p->vars)
ast_variables_destroy(p->vars);
ast_mutex_destroy(&p->lock);
dahdi_close_sub(p, SUB_REAL);
if (p->owner)
p->owner->tech_pvt = NULL;
free(p);
@@ -2806,9 +2826,6 @@ static int destroy_channel(struct dahdi_pvt *prev, struct dahdi_pvt *cur, int no
else
ifend = NULL;
}
if (cur->subs[SUB_REAL].dfd > -1) {
dahdi_close(cur->subs[SUB_REAL].dfd);
}
destroy_dahdi_pvt(&cur);
}
} else {
@@ -2825,9 +2842,6 @@ static int destroy_channel(struct dahdi_pvt *prev, struct dahdi_pvt *cur, int no
else
ifend = NULL;
}
if (cur->subs[SUB_REAL].dfd > -1) {
dahdi_close(cur->subs[SUB_REAL].dfd);
}
destroy_dahdi_pvt(&cur);
}
return 0;
@@ -2849,9 +2863,6 @@ static void destroy_all_channels(void)
/* Free any callerid */
if (p->cidspill)
ast_free(p->cidspill);
/* Close the DAHDI thingy */
if (p->subs[SUB_REAL].dfd > -1)
dahdi_close(p->subs[SUB_REAL].dfd);
pl = p;
p = p->next;
x = pl->channel;
@@ -8010,7 +8021,7 @@ static int pri_create_trunkgroup(int trunkgroup, int *channels)
x = channels[y];
if (ioctl(fd, DAHDI_SPECIFY, &x)) {
ast_log(LOG_WARNING, "Failed to specify channel %d: %s\n", channels[y], strerror(errno));
dahdi_close(fd);
close(fd);
return -1;
}
if (ioctl(fd, DAHDI_GET_PARAMS, &p)) {
@@ -8019,18 +8030,18 @@ static int pri_create_trunkgroup(int trunkgroup, int *channels)
}
if (ioctl(fd, DAHDI_SPANSTAT, &si)) {
ast_log(LOG_WARNING, "Failed go get span information on channel %d (span %d): %s\n", channels[y], p.spanno, strerror(errno));
dahdi_close(fd);
close(fd);
return -1;
}
span = p.spanno - 1;
if (pris[span].trunkgroup) {
ast_log(LOG_WARNING, "Span %d is already provisioned for trunk group %d\n", span + 1, pris[span].trunkgroup);
dahdi_close(fd);
close(fd);
return -1;
}
if (pris[span].pvts[0]) {
ast_log(LOG_WARNING, "Span %d is already provisioned with channels (implicit PRI maybe?)\n", span + 1);
dahdi_close(fd);
close(fd);
return -1;
}
if (!y) {
@@ -8041,7 +8052,7 @@ static int pri_create_trunkgroup(int trunkgroup, int *channels)
pris[ospan].dchannels[y] = channels[y];
pris[ospan].dchanavail[y] |= DCHAN_PROVISIONED;
pris[span].span = span + 1;
dahdi_close(fd);
close(fd);
}
return 0;
}
@@ -9986,7 +9997,7 @@ static int pri_fixup_principle(struct dahdi_pri *pri, int principle, q931_call *
else {
/* Looks good. Drop the pseudo channel now, clear up the assignment, and
wakeup the potential sleeper */
dahdi_close(crv->subs[SUB_REAL].dfd);
dahdi_close_sub(crv, SUB_REAL);
pri->pvts[principle]->call = crv->call;
pri_assign_bearer(crv, pri, pri->pvts[principle]);
ast_debug(1, "Assigning bearer %d/%d to CRV %d:%d\n",
@@ -11334,22 +11345,19 @@ static int start_pri(struct dahdi_pri *pri)
}
res = ioctl(pri->fds[i], DAHDI_GET_PARAMS, &p);
if (res) {
dahdi_close(pri->fds[i]);
pri->fds[i] = -1;
dahdi_close_pri_fd(pri, i);
ast_log(LOG_ERROR, "Unable to get parameters for D-channel %d (%s)\n", x, strerror(errno));
return -1;
}
if ((p.sigtype != DAHDI_SIG_HDLCFCS) && (p.sigtype != DAHDI_SIG_HARDHDLC)) {
dahdi_close(pri->fds[i]);
pri->fds[i] = -1;
dahdi_close_pri_fd(pri, i);
ast_log(LOG_ERROR, "D-channel %d is not in HDLC/FCS mode.\n", x);
return -1;
}
memset(&si, 0, sizeof(si));
res = ioctl(pri->fds[i], DAHDI_SPANSTAT, &si);
if (res) {
dahdi_close(pri->fds[i]);
pri->fds[i] = -1;
dahdi_close_pri_fd(pri, i);
ast_log(LOG_ERROR, "Unable to get span state for D-channel %d (%s)\n", x, strerror(errno));
}
if (!si.alarms)
@@ -11362,8 +11370,7 @@ static int start_pri(struct dahdi_pri *pri)
bi.bufsize = 1024;
if (ioctl(pri->fds[i], DAHDI_SET_BUFINFO, &bi)) {
ast_log(LOG_ERROR, "Unable to set appropriate buffering on channel %d: %s\n", x, strerror(errno));
dahdi_close(pri->fds[i]);
pri->fds[i] = -1;
dahdi_close_pri_fd(pri, i);
return -1;
}
switch (pri->sig) {
@@ -11387,8 +11394,7 @@ static int start_pri(struct dahdi_pri *pri)
if (i)
pri_enslave(pri->dchans[0], pri->dchans[i]);
if (!pri->dchans[i]) {
dahdi_close(pri->fds[i]);
pri->fds[i] = -1;
dahdi_close_pri_fd(pri, i);
ast_log(LOG_ERROR, "Unable to create PRI structure\n");
return -1;
}
@@ -11408,8 +11414,7 @@ static int start_pri(struct dahdi_pri *pri)
for (i = 0; i < NUM_DCHANS; i++) {
if (!pri->dchannels[i])
break;
dahdi_close(pri->fds[i]);
pri->fds[i] = -1;
dahdi_close_pri_fd(pri, i);
}
ast_log(LOG_ERROR, "Unable to spawn D-channel: %s\n", strerror(errno));
return -1;
@@ -11888,7 +11893,7 @@ static int dahdi_restart(void)
#ifdef HAVE_PRI
for (i = 0; i < NUM_SPANS; i++) {
for (j = 0; j < NUM_DCHANS; j++)
dahdi_close(pris[i].fds[j]);
dahdi_close_pri_fd(&(pris[i]), j);
}
memset(pris, 0, sizeof(pris));
@@ -11905,7 +11910,7 @@ static int dahdi_restart(void)
#ifdef HAVE_SS7
for (i = 0; i < NUM_SPANS; i++) {
for (j = 0; j < NUM_DCHANS; j++)
dahdi_close(linksets[i].fds[j]);
dahdi_close_ss7_fd(&(linksets[i]), j);
}
memset(linksets, 0, sizeof(linksets));
@@ -12904,14 +12909,12 @@ static int linkset_addsigchan(int sigchan)
}
res = ioctl(link->fds[curfd], DAHDI_GET_PARAMS, &p);
if (res) {
dahdi_close(link->fds[curfd]);
link->fds[curfd] = -1;
dahdi_close_ss7_fd(link, curfd);
ast_log(LOG_ERROR, "Unable to get parameters for sigchan %d (%s)\n", sigchan, strerror(errno));
return -1;
}
if ((p.sigtype != DAHDI_SIG_HDLCFCS) && (p.sigtype != DAHDI_SIG_HARDHDLC) && (p.sigtype != DAHDI_SIG_MTP2)) {
dahdi_close(link->fds[curfd]);
link->fds[curfd] = -1;
dahdi_close_ss7_fd(link, curfd);
ast_log(LOG_ERROR, "sigchan %d is not in HDLC/FCS mode.\n", sigchan);
return -1;
}
@@ -12923,8 +12926,7 @@ static int linkset_addsigchan(int sigchan)
if (ioctl(link->fds[curfd], DAHDI_SET_BUFINFO, &bi)) {
ast_log(LOG_ERROR, "Unable to set appropriate buffering on channel %d: %s\n", sigchan, strerror(errno));
dahdi_close(link->fds[curfd]);
link->fds[curfd] = -1;
dahdi_close_ss7_fd(link, curfd);
return -1;
}
@@ -12938,8 +12940,7 @@ static int linkset_addsigchan(int sigchan)
memset(&si, 0, sizeof(si));
res = ioctl(link->fds[curfd], DAHDI_SPANSTAT, &si);
if (res) {
dahdi_close(link->fds[curfd]);
link->fds[curfd] = -1;
dahdi_close_ss7_fd(link, curfd);
ast_log(LOG_ERROR, "Unable to get span state for sigchan %d (%s)\n", sigchan, strerror(errno));
}
@@ -13287,8 +13288,7 @@ static struct ast_cli_entry dahdi_ss7_cli[] = {
static int __unload_module(void)
{
int x;
struct dahdi_pvt *p, *pl;
struct dahdi_pvt *p;
#if defined(HAVE_PRI) || defined(HAVE_SS7)
int i, j;
#endif
@@ -13336,34 +13336,14 @@ static int __unload_module(void)
monitor_thread = AST_PTHREADT_STOP;
ast_mutex_unlock(&monlock);
ast_mutex_lock(&iflock);
/* Destroy all the interfaces and free their memory */
p = iflist;
while (p) {
/* Free any callerid */
if (p->cidspill)
ast_free(p->cidspill);
/* Close the DAHDI thingy */
if (p->subs[SUB_REAL].dfd > -1)
dahdi_close(p->subs[SUB_REAL].dfd);
pl = p;
p = p->next;
x = pl->channel;
/* Free associated memory */
if (pl)
destroy_dahdi_pvt(&pl);
ast_verb(3, "Unregistered channel %d\n", x);
}
iflist = NULL;
ifcount = 0;
ast_mutex_unlock(&iflock);
destroy_all_channels();
#if defined(HAVE_PRI)
for (i = 0; i < NUM_SPANS; i++) {
if (pris[i].master && (pris[i].master != AST_PTHREADT_NULL))
pthread_join(pris[i].master, NULL);
for (j = 0; j < NUM_DCHANS; j++) {
dahdi_close(pris[i].fds[j]);
dahdi_close_pri_fd(&(pris[i]), j);
}
}
#endif
@@ -13373,7 +13353,7 @@ static int __unload_module(void)
if (linksets[i].master && (linksets[i].master != AST_PTHREADT_NULL))
pthread_join(linksets[i].master, NULL);
for (j = 0; j < NUM_DCHANS; j++) {
dahdi_close(linksets[i].fds[j]);
dahdi_close_ss7_fd(&(linksets[i]), j);
}
}
#endif

View File

@@ -5113,20 +5113,30 @@ static int load_module(void)
ast_cli_register_multiple(chan_misdn_clis, sizeof(chan_misdn_clis) / sizeof(struct ast_cli_entry));
ast_register_application("misdn_set_opt", misdn_set_opt_exec, "misdn_set_opt",
"misdn_set_opt(:<opt><optarg>:<opt><optarg>..):\n"
"Sets mISDN opts. and optargs\n"
"\n"
"The available options are:\n"
" d - Send display text on called phone, text is the optparam\n"
" n - don't detect dtmf tones on called channel\n"
" h - make digital outgoing call\n"
" c - make crypted outgoing call, param is keyindex\n"
" e - perform echo cancelation on this channel,\n"
" takes taps as arguments (32,64,128,256)\n"
" s - send Non Inband DTMF as inband\n"
" vr - rxgain control\n"
" vt - txgain control\n"
" i - Ignore detected dtmf tones, don't signal them to asterisk, they will be transported inband.\n"
"misdn_set_opt(:<opt><optarg>:<opt><optarg>...):\n"
"Sets mISDN opts. and optargs\n"
"\n"
"The available options are:\n"
" a - Have Asterisk detect DTMF tones on called channel\n"
" c - Make crypted outgoing call, optarg is keyindex\n"
" d - Send display text to called phone, text is the optarg\n"
" e - Perform echo cancelation on this channel,\n"
" takes taps as optarg (32,64,128,256)\n"
" e! - Disable echo cancelation on this channel\n"
" f - Enable fax detection\n"
" h - Make digital outgoing call\n"
" h1 - Make HDLC mode digital outgoing call\n"
" i - Ignore detected DTMF tones, don't signal them to Asterisk,\n"
" they will be transported inband.\n"
" jb - Set jitter buffer length, optarg is length\n"
" jt - Set jitter buffer upper threshold, optarg is threshold\n"
" jn - Disable jitter buffer\n"
" n - disable DSP on channel, disables: Echocancel, DTMF Detection and Volume Control.\n"
" p - Caller ID presentation,\n"
" optarg is either 'allowed' or 'restricted'\n"
" s - Send Non-inband DTMF as inband\n"
" vr - Rx gain control, optarg is gain\n"
" vt - Tx gain control, optarg is gain\n"
);

View File

@@ -3134,12 +3134,18 @@ static int test_inuse(struct misdn_bchannel *bc)
struct timeval now;
gettimeofday(&now, NULL);
if (!bc->in_use) {
if (misdn_lib_port_is_pri(bc->port) && bc->last_used.tv_sec == now.tv_sec ) {
if ( bc->last_used.tv_sec == now.tv_sec ) {
cb_log(2,bc->port, "channel with stid:%x for one second still in use! (n:%d lu:%d)\n", bc->b_stid, (int) now.tv_sec, (int) bc->last_used.tv_sec);
return 1;
}
cb_log(3,bc->port, "channel with stid:%x not in use!\n", bc->b_stid);
return 0;
}
return 0;
cb_log(2,bc->port, "channel with stid:%x in use!\n", bc->b_stid);
return 1;
}
@@ -3188,9 +3194,15 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, i
if (channel > 0) {
if (channel <= stack->b_num) {
for (i = 0; i < stack->b_num; i++) {
if ( test_inuse(&stack->bc[i]) && stack->bc[i].channel == channel) {
cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
return NULL;
if ( stack->bc[i].channel == channel) {
if (test_inuse(&stack->bc[i])) {
cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
return NULL;
} else {
prepare_bc(&stack->bc[i], channel);
return &stack->bc[i];
}
}
}
} else {
@@ -3203,7 +3215,7 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, i
if (dec) {
for (i = maxnum-1; i>=0; i--) {
if (test_inuse(&stack->bc[i])) {
if (!test_inuse(&stack->bc[i])) {
/* 3. channel on bri means CW*/
if (!stack->pri && i==stack->b_num)
stack->bc[i].cw=1;
@@ -3215,7 +3227,7 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, i
}
} else {
for (i = 0; i <maxnum; i++) {
if (test_inuse(&stack->bc[i])) {
if (!test_inuse(&stack->bc[i])) {
/* 3. channel on bri means CW*/
if (!stack->pri && i==stack->b_num)
stack->bc[i].cw=1;

View File

@@ -2162,7 +2162,7 @@ static int action_originate(struct mansession *s, const struct message *m)
int format = AST_FORMAT_SLINEAR;
pthread_t th;
if (!name) {
if (!ast_strlen_zero(name)) {
astman_send_error(s, m, "Channel not specified");
return 0;
}