diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-26 22:25:43 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-26 22:25:43 +0000 |
commit | e2c75a92f97e22fed0bd2017fccb550fc2106ba3 (patch) | |
tree | 8cc9a36b9066a72d36a623a08bb8779286caedf2 /channels | |
parent | b561eb0a2d237ca6c387b60011d55fc38bec1c2c (diff) |
Pass concept of status back, permit "leaveempty" to work with static agents who are not loggedon (bug #2719)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4106 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-x | channels/chan_agent.c | 9 | ||||
-rwxr-xr-x | channels/chan_alsa.c | 4 | ||||
-rwxr-xr-x | channels/chan_h323.c | 3 | ||||
-rwxr-xr-x | channels/chan_iax2.c | 5 | ||||
-rwxr-xr-x | channels/chan_local.c | 2 | ||||
-rwxr-xr-x | channels/chan_mgcp.c | 5 | ||||
-rwxr-xr-x | channels/chan_modem.c | 2 | ||||
-rwxr-xr-x | channels/chan_nbs.c | 2 | ||||
-rwxr-xr-x | channels/chan_oss.c | 4 | ||||
-rwxr-xr-x | channels/chan_phone.c | 6 | ||||
-rwxr-xr-x | channels/chan_sip.c | 3 | ||||
-rwxr-xr-x | channels/chan_skinny.c | 2 | ||||
-rwxr-xr-x | channels/chan_vpb.c | 2 | ||||
-rwxr-xr-x | channels/chan_zap.c | 22 |
14 files changed, 39 insertions, 32 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c index d16677c7d..8e596a44f 100755 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -34,6 +34,7 @@ #include <asterisk/manager.h> #include <asterisk/features.h> #include <asterisk/utils.h> +#include <asterisk/causes.h> #include <sys/socket.h> #include <errno.h> #include <unistd.h> @@ -1051,7 +1052,7 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock) return res; } -static struct ast_channel *agent_request(const char *type, int format, void *data) +static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause) { struct agent_pvt *p; struct ast_channel *chan = NULL; @@ -1113,7 +1114,7 @@ static struct ast_channel *agent_request(const char *type, int format, void *dat chan = agent_new(p, AST_STATE_DOWN); } else if (!p->owner && !ast_strlen_zero(p->loginchan)) { /* Adjustable agent */ - p->chan = ast_request("Local", format, p->loginchan); + p->chan = ast_request("Local", format, p->loginchan, cause); if (p->chan) chan = agent_new(p, AST_STATE_DOWN); } @@ -1142,6 +1143,10 @@ static struct ast_channel *agent_request(const char *type, int format, void *dat } else ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s); } + if (hasagent) + *cause = AST_CAUSE_BUSY; + else + *cause = AST_CAUSE_UNREGISTERED; ast_mutex_unlock(&agentlock); return chan; } diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index 09074ec87..e00eecd44 100755 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -19,6 +19,7 @@ #include <asterisk/config.h> #include <asterisk/cli.h> #include <asterisk/utils.h> +#include <asterisk/causes.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> @@ -753,7 +754,7 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state) return tmp; } -static struct ast_channel *alsa_request(const char *type, int format, void *data) +static struct ast_channel *alsa_request(const char *type, int format, void *data, int *cause) { int oldformat = format; struct ast_channel *tmp=NULL; @@ -765,6 +766,7 @@ static struct ast_channel *alsa_request(const char *type, int format, void *data ast_mutex_lock(&alsalock); if (alsa.owner) { ast_log(LOG_NOTICE, "Already have a call on the ALSA channel\n"); + *cause = AST_CAUSE_BUSY; } else { tmp= alsa_new(&alsa, AST_STATE_DOWN); if (!tmp) { diff --git a/channels/chan_h323.c b/channels/chan_h323.c index a405567cb..8965fc125 100755 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -66,6 +66,7 @@ extern "C" { #include <asterisk/callerid.h> #include <asterisk/cli.h> #include <asterisk/dsp.h> +#include <asterisk/causes.h> #ifdef __cplusplus } #endif @@ -948,7 +949,7 @@ static int create_addr(struct oh323_pvt *pvt, char *opeer) return 0; } } -static struct ast_channel *oh323_request(const char *type, int format, void *data) +static struct ast_channel *oh323_request(const char *type, int format, void *data, int *cause) { int oldformat; struct oh323_pvt *pvt; diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index ed87ad994..733490e09 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -35,6 +35,7 @@ #include <asterisk/musiconhold.h> #include <asterisk/features.h> #include <asterisk/utils.h> +#include <asterisk/causes.h> #include <sys/mman.h> #include <arpa/inet.h> #include <dirent.h> @@ -6208,7 +6209,7 @@ static void free_context(struct iax2_context *con) } } -static struct ast_channel *iax2_request(const char *type, int format, void *data) +static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause) { int callno; int res; @@ -6248,6 +6249,7 @@ static struct ast_channel *iax2_request(const char *type, int format, void *data /* Populate our address from the given */ if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, ¬ransfer, &usejitterbuf, NULL, 0, NULL, 0, &found, NULL)) { + *cause = AST_CAUSE_UNREGISTERED; return NULL; } if (portno) { @@ -6256,6 +6258,7 @@ static struct ast_channel *iax2_request(const char *type, int format, void *data callno = find_callno(0, 0, &sin, NEW_FORCE, 1); if (callno < 1) { ast_log(LOG_WARNING, "Unable to create call\n"); + *cause = AST_CAUSE_CONGESTION; return NULL; } ast_mutex_lock(&iaxsl[callno]); diff --git a/channels/chan_local.c b/channels/chan_local.c index 8b2c5be54..661ab403e 100755 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -462,7 +462,7 @@ static struct ast_channel *local_new(struct local_pvt *p, int state) } -static struct ast_channel *local_request(const char *type, int format, void *data) +static struct ast_channel *local_request(const char *type, int format, void *data, int *cause) { struct local_pvt *p; struct ast_channel *chan = NULL; diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index a66fb6d8d..0b1fafd83 100755 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -72,6 +72,7 @@ #include <asterisk/app.h> #include <asterisk/musiconhold.h> #include <asterisk/utils.h> +#include <asterisk/causes.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <net/if.h> @@ -3342,7 +3343,7 @@ static int restart_monitor(void) return 0; } -static struct ast_channel *mgcp_request(const char *type, int format, void *data) +static struct ast_channel *mgcp_request(const char *type, int format, void *data, int *cause) { int oldformat; struct mgcp_subchannel *sub; @@ -3364,6 +3365,7 @@ static struct ast_channel *mgcp_request(const char *type, int format, void *data sub = find_subchannel(tmp, 0, NULL); if (!sub) { ast_log(LOG_WARNING, "Unable to find MGCP endpoint '%s'\n", tmp); + *cause = AST_CAUSE_UNREGISTERED; return NULL; } @@ -3383,6 +3385,7 @@ static struct ast_channel *mgcp_request(const char *type, int format, void *data transmit_notify_request(sub,"L/vmwi(-)"); } } + *cause = AST_CAUSE_BUSY; return NULL; } tmpc = mgcp_new(sub->owner ? sub->next : sub, AST_STATE_DOWN); diff --git a/channels/chan_modem.c b/channels/chan_modem.c index c6a27f1a4..41d95540b 100755 --- a/channels/chan_modem.c +++ b/channels/chan_modem.c @@ -773,7 +773,7 @@ static struct ast_modem_pvt *mkif(char *iface) return tmp; } -static struct ast_channel *modem_request(const char *type, int format, void *data) +static struct ast_channel *modem_request(const char *type, int format, void *data, int *cause) { int oldformat; struct ast_modem_pvt *p; diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c index 6f67b3ada..b3fdfbf93 100755 --- a/channels/chan_nbs.c +++ b/channels/chan_nbs.c @@ -232,7 +232,7 @@ static struct ast_channel *nbs_new(struct nbs_pvt *i, int state) } -static struct ast_channel *nbs_request(const char *type, int format, void *data) +static struct ast_channel *nbs_request(const char *type, int format, void *data, int *cause) { int oldformat; struct nbs_pvt *p; diff --git a/channels/chan_oss.c b/channels/chan_oss.c index c1d5ee0b3..ad87a9128 100755 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -26,6 +26,7 @@ #include <asterisk/config.h> #include <asterisk/cli.h> #include <asterisk/utils.h> +#include <asterisk/causes.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> @@ -745,7 +746,7 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state) return tmp; } -static struct ast_channel *oss_request(const char *type, int format, void *data) +static struct ast_channel *oss_request(const char *type, int format, void *data, int *cause) { int oldformat = format; struct ast_channel *tmp; @@ -756,6 +757,7 @@ static struct ast_channel *oss_request(const char *type, int format, void *data) } if (oss.owner) { ast_log(LOG_NOTICE, "Already have a call on the OSS channel\n"); + *cause = AST_CAUSE_BUSY; return NULL; } tmp= oss_new(&oss, AST_STATE_DOWN); diff --git a/channels/chan_phone.c b/channels/chan_phone.c index b91b3657f..b81c5b04d 100755 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -23,6 +23,7 @@ #include <asterisk/options.h> #include <asterisk/utils.h> #include <asterisk/callerid.h> +#include <asterisk/causes.h> #include <sys/socket.h> #include <sys/time.h> #include <errno.h> @@ -1023,7 +1024,7 @@ static struct phone_pvt *mkif(char *iface, int mode, int txgain, int rxgain) return tmp; } -static struct ast_channel *phone_request(const char *type, int format, void *data) +static struct ast_channel *phone_request(const char *type, int format, void *data, int *cause) { int oldformat; struct phone_pvt *p; @@ -1047,7 +1048,8 @@ static struct ast_channel *phone_request(const char *type, int format, void *dat if (!p->owner) { tmp = phone_new(p, AST_STATE_DOWN, p->context); break; - } + } else + *cause = AST_CAUSE_BUSY; } p = p->next; } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 56acb1683..2181c6d87 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -7946,7 +7946,7 @@ static int sip_devicestate(void *data) /*--- sip_request: PBX interface function -build SIP pvt structure ---*/ /* SIP calls initiated by the PBX arrive here */ -static struct ast_channel *sip_request(const char *type, int format, void *data) +static struct ast_channel *sip_request(const char *type, int format, void *data, int *cause) { int oldformat; struct sip_pvt *p; @@ -7990,6 +7990,7 @@ static struct ast_channel *sip_request(const char *type, int format, void *data) p->capability = global_capability; if (create_addr(p, host)) { + *cause = AST_CAUSE_UNREGISTERED; sip_destroy(p); return NULL; } diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index a77c4b18f..dbf27977b 100755 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -2489,7 +2489,7 @@ static int restart_monitor(void) return 0; } -static struct ast_channel *skinny_request(const char *type, int format, void *data) +static struct ast_channel *skinny_request(const char *type, int format, void *data, int *cause) { int oldformat; struct skinny_subchannel *sub; diff --git a/channels/chan_vpb.c b/channels/chan_vpb.c index 617367f95..82044e77c 100755 --- a/channels/chan_vpb.c +++ b/channels/chan_vpb.c @@ -2115,7 +2115,7 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, int state, char *context) return tmp; } -static struct ast_channel *vpb_request(const char *type, int format, void *data) +static struct ast_channel *vpb_request(const char *type, int format, void *data, int *cause) { int oldformat; struct vpb_pvt *p; diff --git a/channels/chan_zap.c b/channels/chan_zap.c index 07fe9ca51..1590252cd 100755 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -6732,7 +6732,7 @@ static int pri_find_empty_chan(struct zt_pri *pri, int backwards) } #endif -static struct ast_channel *zt_request(const char *type, int format, void *data) +static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause) { int oldformat; int groupmatch = 0; @@ -6945,21 +6945,8 @@ next: } ast_mutex_unlock(lock); restart_monitor(); - if (!tmp) { - if (busy && (channelmatch != CHAN_PSEUDO)) { - tmp = zt_request("Zap", format, "pseudo"); - if (tmp) { - char newname[80]; - ast_mutex_lock(&tmp->lock); - snprintf(newname, sizeof(newname), "Zap/%s-busy-%d", (char *)data, rand()); - ast_change_name(tmp, newname); - ast_setstate(tmp, AST_STATE_BUSY); - ast_mutex_unlock(&tmp->lock); - } - } else if (busy) { - ast_log(LOG_WARNING, "Whoa, the pseudo was busy somehow!\n"); - } - } + if (callwait || (!tmp && busy)) + *cause = AST_CAUSE_BUSY; return tmp; } @@ -7200,6 +7187,7 @@ static void *pri_dchannel(void *vpri) time_t t; int i, which=-1; int numdchans; + int cause=0; struct zt_pvt *crv; pthread_t threadid; pthread_attr_t attr; @@ -7277,7 +7265,7 @@ static void *pri_dchannel(void *vpri) (tv.tv_usec - lastidle.tv_usec) / 1000) > 1000) { /* Don't create a new idle call more than once per second */ snprintf(idlen, sizeof(idlen), "%d/%s", pri->pvts[nextidle]->channel, pri->idledial); - idle = zt_request("Zap", AST_FORMAT_ULAW, idlen); + idle = zt_request("Zap", AST_FORMAT_ULAW, idlen, &cause); if (idle) { pri->pvts[nextidle]->isidlecall = 1; if (ast_pthread_create(&p, NULL, do_idle_thread, idle)) { |