Index: channels/chan_zap.c
===================================================================
--- channels/chan_zap.c	(revision 32350)
+++ channels/chan_zap.c	(working copy)
@@ -10231,6 +10231,7 @@
 	int y;
 	int found_pseudo = 0;
 	int cur_radio = 0;
+        int ret = 0;
 #ifdef HAVE_LIBPRI
 	int spanno;
 	int i;
@@ -10242,10 +10243,10 @@
 
 	cfg = ast_config_load(config);
 
-	/* We *must* have a config file otherwise stop immediately */
+	/* We *must* have a config file otherwise don't configure chan_zap */
 	if (!cfg) {
 		ast_log(LOG_ERROR, "Unable to load config %s\n", config);
-		return -1;
+		return 0;
 	}
 	
 
@@ -10265,7 +10266,7 @@
 						while (c && (i < NUM_DCHANS)) {
 							dchannels[i] = atoi(c + 1);
 							if (dchannels[i] < 0) {
-								ast_log(LOG_WARNING, "D-channel for trunk group %d must be a postiive number at line %d of zapata.conf\n", trunkgroup, v->lineno);
+								ast_log(LOG_WARNING, "D-channel for trunk group %d must be a positive number at line %d of zapata.conf\n", trunkgroup, v->lineno);
 							} else
 								i++;
 							c = strchr(c + 1, ',');
@@ -10327,9 +10328,7 @@
 			if (reload == 0) {
 				if (cur_signalling < 0) {
 					ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
-					ast_config_destroy(cfg);
-					ast_mutex_unlock(&iflock);
-					return -1;
+                                        goto err_lock;
 				}
 			}
 			c = v->value;
@@ -10338,16 +10337,12 @@
 			pri = NULL;
 			if (!strcasecmp(v->name, "crv")) {
 				if (sscanf(c, "%d:%n", &trunkgroup, &y) != 1) {
-					ast_log(LOG_WARNING, "CRV must begin with trunkgroup followed by a colon at line %d\n", v->lineno);
-					ast_config_destroy(cfg);
-					ast_mutex_unlock(&iflock);
-					return -1;
+					ast_log(LOG_ERROR, "CRV must begin with trunkgroup followed by a colon at line %d\n", v->lineno);
+                                        goto err_lock;
 				}
 				if (trunkgroup < 1) {
-					ast_log(LOG_WARNING, "CRV trunk group must be a postive number at line %d\n", v->lineno);
-					ast_config_destroy(cfg);
-					ast_mutex_unlock(&iflock);
-					return -1;
+					ast_log(LOG_ERROR, "CRV trunk group must be a postive number at line %d\n", v->lineno);
+                                        goto err_lock;
 				}
 				c += y;
 				for (y = 0; y < NUM_SPANS; y++) {
@@ -10357,10 +10352,8 @@
 					}
 				}
 				if (!pri) {
-					ast_log(LOG_WARNING, "No such trunk group %d at CRV declaration at line %d\n", trunkgroup, v->lineno);
-					ast_config_destroy(cfg);
-					ast_mutex_unlock(&iflock);
-					return -1;
+					ast_log(LOG_ERROR, "No such trunk group %d at CRV declaration at line %d\n", trunkgroup, v->lineno);
+                                        goto err_lock;
 				}
 			}
 #endif			
@@ -10376,9 +10369,7 @@
 					found_pseudo = 1;
 				} else {
 					ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
-					ast_config_destroy(cfg);
-					ast_mutex_unlock(&iflock);
-					return -1;
+                                        goto err_lock;
 				}
 				if (finish < start) {
 					ast_log(LOG_WARNING, "Sillyness: %d < %d\n", start, finish);
@@ -10408,9 +10399,7 @@
 							ast_log(LOG_ERROR, "Unable to reconfigure channel '%s'\n", v->value);
 						else
 							ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
-						ast_config_destroy(cfg);
-						ast_mutex_unlock(&iflock);
-						return -1;
+                                                goto err_lock;
 					}
 				}
 				chan = strsep(&c, ",");
@@ -10807,9 +10796,7 @@
 					switchtype = PRI_SWITCH_QSIG;
 				else {
 					ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
-					ast_config_destroy(cfg);
-					ast_mutex_unlock(&iflock);
-					return -1;
+                                        goto err_lock;
 				}
 			} else if (!strcasecmp(v->name, "nsf")) {
 				if (!strcasecmp(v->value, "sdn"))
@@ -10995,7 +10982,7 @@
 				ctlfd = open("/dev/zap/ctl", O_RDWR);
 				if (ctlfd == -1) {
 					ast_log(LOG_ERROR, "Unable to open /dev/zap/ctl to set toneduration\n");
-					return -1;
+                                        goto err_lock;
 				}
 
 				toneduration = atoi(v->value);
@@ -11004,7 +10991,7 @@
 					res = ioctl(ctlfd, ZT_SET_DIALPARAMS, &dps);
 					if (res < 0) {
 						ast_log(LOG_ERROR, "Invalid tone duration: %d ms\n", toneduration);
-						return -1;
+                                                goto err_lock;
 					}
 				}
 				close(ctlfd);
@@ -11044,13 +11031,14 @@
 	}
 	ast_mutex_unlock(&iflock);
 	ast_config_destroy(cfg);
+        cfg=NULL;
 #ifdef HAVE_LIBPRI
 	if (!reload) {
 		for (x = 0; x < NUM_SPANS; x++) {
 			if (pris[x].pvts[0]) {
 				if (start_pri(pris + x)) {
 					ast_log(LOG_ERROR, "Unable to start D-channel on span %d\n", x + 1);
-					return -1;
+					return 0;
 				} else if (option_verbose > 1)
 					ast_verbose(VERBOSE_PREFIX_2 "Starting D-Channel on span %d\n", x + 1);
 			}
@@ -11060,6 +11048,13 @@
 	/* And start the monitor for the first time */
 	restart_monitor();
 	return 0;
+
+err_lock:
+        ast_log(LOG_NOTICE, "Giving up on chan_zap.so config, reload flag: %d, return value: %d.\n", reload, ret);
+        ast_mutex_unlock(&iflock);
+        if (cfg != NULL) 
+		ast_config_destroy(cfg);
+        return ret;
 }
 
 static int load_module(void *mod)
