Index: channels/chan_zap.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v retrieving revision 1.165 diff -u -r1.165 chan_zap.c --- channels/chan_zap.c 12 Jan 2004 16:59:57 -0000 1.165 +++ channels/chan_zap.c 15 Jan 2004 19:34:34 -0000 @@ -1,3 +1,4 @@ + /* * Asterisk -- A telephony toolkit for Linux. * @@ -5129,6 +5130,7 @@ tmp = (struct zt_pvt*)malloc(sizeof(struct zt_pvt)); if (!tmp) { ast_log(LOG_ERROR, "MALLOC FAILED\n"); + free(tmp); return NULL; } memset(tmp, 0, sizeof(struct zt_pvt)); @@ -5200,7 +5202,8 @@ if (p.sigtype != (signalling & 0xffff)) { ast_log(LOG_ERROR, "Signalling requested is %s but line is in %s signalling\n", sig2str(signalling), sig2str(p.sigtype)); free(tmp); - return NULL; + tmp = NULL; + return tmp; } if (here) { if (tmp->sig != signalling) { @@ -6670,8 +6673,7 @@ " Enables debugging down to the Q.921 level\n"; static struct ast_cli_entry pri_debug = { - { "pri", "debug", "span", NULL }, handle_pri_debug, "Enables PRI debugging on a span", pri_debug_help, complete_span -}; + { "pri", "debug", "span", NULL }, handle_pri_debug, "Enables PRI debugging on a span", pri_debug_help, complete_span }; static struct ast_cli_entry pri_no_debug = { { "pri", "no", "debug", "span", NULL }, handle_pri_no_debug, "Disables PRI debugging on a span", pri_no_debug_help, complete_span }; @@ -7026,13 +7028,30 @@ static int __unload_module(void) { + int x = 0; + int i; struct zt_pvt *p, *pl; - /* First, take us out of the channel loop */ - ast_channel_unregister(type); - ast_channel_unregister(typecompat); +#ifdef ZAPATA_PRI + for(i=0;iowner, AST_SOFTHANGUP_APPUNLOAD); p = p->next; } - iflist = NULL; ast_mutex_unlock(&iflock); } else { ast_log(LOG_WARNING, "Unable to lock the monitor\n"); @@ -7072,8 +7090,11 @@ zt_close(p->subs[SUB_REAL].zfd); pl = p; p = p->next; + x++; /* Free associated memory */ - free(pl); + if(p) + free(pl); + ast_verbose(VERBOSE_PREFIX_3 "Unregistered channel %d\n", x); } iflist = NULL; ast_mutex_unlock(&iflock); @@ -7081,7 +7102,12 @@ ast_log(LOG_WARNING, "Unable to lock the monitor\n"); return -1; } - +#ifdef ZAPATA_PRI + for(i=0;i 2) ast_verbose(VERBOSE_PREFIX_3 "Registered channel %d, %s signalling\n", x, sig2str(tmp->sig)); @@ -7162,7 +7189,7 @@ ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value); ast_destroy(cfg); ast_mutex_unlock(&iflock); - __unload_module(); + /*__unload_module();*/ return -1; } } @@ -7482,6 +7509,9 @@ #endif res = setup_zap(); /* Make sure we can register our Zap channel type */ + if(res) { + return -1; + } if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) { ast_log(LOG_ERROR, "Unable to register channel class %s\n", type); __unload_module();