[asterisk-commits] murf: branch murf/bug11210 r114070 - in /team/murf/bug11210: ./ channels/ con...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 11 16:18:56 CDT 2008


Author: murf
Date: Fri Apr 11 16:18:56 2008
New Revision: 114070

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114070
Log:
Merged revisions 114042-114069 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r114042 | tilghman | 2008-04-10 13:04:29 -0600 (Thu, 10 Apr 2008) | 7 lines
  
  The hydra grows yet another head...
  (closes issue #12401)
   Reported by: davevg
   Patches: 
         astcli.diff2 uploaded by davevg (license 209)
   Tested by: davevg, Corydon76
................
  r114046 | mmichelson | 2008-04-10 13:58:36 -0600 (Thu, 10 Apr 2008) | 14 lines
  
  Merged revisions 114045 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r114045 | mmichelson | 2008-04-10 14:55:33 -0500 (Thu, 10 Apr 2008) | 6 lines
  
  Be sure that we're not about to set bridgepvt NULL prior to dereferencing it.
  
  (closes issue #11775)
  Reported by: fujin
  
  
  ........
................
  r114049 | file | 2008-04-10 14:28:40 -0600 (Thu, 10 Apr 2008) | 2 lines
  
  A 'b' option has been added which causes chan_local to return the actual channel that is behind it when queried. This is useful for transfer scenarios as the actual channel will be transferred, not the Local channel. If you have been using Local channels as queue members and having issues when the agent did a blind transfer this option may solve the issue.
................
  r114052 | mmichelson | 2008-04-10 16:02:32 -0600 (Thu, 10 Apr 2008) | 11 lines
  
  Merged revisions 114051 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r114051 | mmichelson | 2008-04-10 15:59:49 -0500 (Thu, 10 Apr 2008) | 3 lines
  
  Fix 1.4 build when LOW_MEMORY is enabled.
  
  
  ........
................
  r114061 | tilghman | 2008-04-11 08:54:22 -0600 (Fri, 11 Apr 2008) | 6 lines
  
  Errors are all greater than 0
  (closes issue #12422)
   Reported by: nito
   Patches: 
         res_config_ldap_result_check_patch.diff uploaded by nito (license 340)
................
  r114064 | mmichelson | 2008-04-11 09:49:35 -0600 (Fri, 11 Apr 2008) | 19 lines
  
  Merged revisions 114063 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r114063 | mmichelson | 2008-04-11 10:44:28 -0500 (Fri, 11 Apr 2008) | 11 lines
  
  Fix a race condition that may happen between a sip hangup
  and a "core show channel" command. This patch adds locking
  to prevent the resulting crash.
  
  (closes issue #12155)
  Reported by: tsearle
  Patches:
        show_channels_crash2.patch uploaded by tsearle (license 373)
  Tested by: tsearle
  
  
  ........
................
  r114067 | twilson | 2008-04-11 15:04:46 -0600 (Fri, 11 Apr 2008) | 3 lines
  
  Fix the fact that global_variables 1) weren't being updated on reload (thanks for the report, Doug), and 2) weren't actually being appended to the list of profile variables because build_profile was called before the list was populated. Also needed to free the contents returned by load_file().
................

Modified:
    team/murf/bug11210/   (props changed)
    team/murf/bug11210/CHANGES
    team/murf/bug11210/channels/chan_local.c
    team/murf/bug11210/channels/chan_sip.c
    team/murf/bug11210/contrib/scripts/astcli
    team/murf/bug11210/include/asterisk/lock.h
    team/murf/bug11210/main/features.c
    team/murf/bug11210/main/manager.c
    team/murf/bug11210/main/utils.c
    team/murf/bug11210/res/res_config_ldap.c
    team/murf/bug11210/res/res_phoneprov.c
    team/murf/bug11210/utils/Makefile
    team/murf/bug11210/utils/ael_main.c
    team/murf/bug11210/utils/astman.c
    team/murf/bug11210/utils/check_expr.c
    team/murf/bug11210/utils/conf2ael.c
    team/murf/bug11210/utils/hashtest.c
    team/murf/bug11210/utils/hashtest2.c

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Apr 11 16:18:56 2008
@@ -1,1 +1,1 @@
-/trunk:1-114041
+/trunk:1-114069

Modified: team/murf/bug11210/CHANGES
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/CHANGES?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/CHANGES (original)
+++ team/murf/bug11210/CHANGES Fri Apr 11 16:18:56 2008
@@ -260,6 +260,9 @@
      SIP call to Voicemail by putting a Local channel in the middle.  This
      feature is enabled by using the 'j' option in the Dial string to the Local
      channel in conjunction with the existing 'n' option for local channels.
+  * A 'b' option has been added which causes chan_local to return the actual channel
+     that is behind it when queried. This is useful for transfer scenarios as the
+     actual channel will be transferred, not the Local channel.
 
 Zaptel channel driver (chan_zap) Changes
 ----------------------------------------

Modified: team/murf/bug11210/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_local.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/channels/chan_local.c (original)
+++ team/murf/bug11210/channels/chan_local.c Fri Apr 11 16:18:56 2008
@@ -74,6 +74,7 @@
 static int local_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
 static int local_sendtext(struct ast_channel *ast, const char *text);
 static int local_devicestate(void *data);
+static struct ast_channel *local_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge);
 
 /* PBX interface structure for channel registration */
 static const struct ast_channel_tech local_tech = {
@@ -95,6 +96,7 @@
 	.send_html = local_sendhtml,
 	.send_text = local_sendtext,
 	.devicestate = local_devicestate,
+	.bridged_channel = local_bridgedchannel,
 };
 
 struct local_pvt {
@@ -116,6 +118,7 @@
 #define LOCAL_ALREADY_MASQED  (1 << 2) /*!< Already masqueraded */
 #define LOCAL_LAUNCHED_PBX    (1 << 3) /*!< PBX was launched */
 #define LOCAL_NO_OPTIMIZATION (1 << 4) /*!< Do not optimize using masquerading */
+#define LOCAL_BRIDGE          (1 << 5) /*!< Report back the "true" channel as being bridged to */
 
 static AST_LIST_HEAD_STATIC(locals, local_pvt);
 
@@ -165,6 +168,28 @@
 	ast_mutex_destroy(&pvt->lock);
 	ast_free(pvt);
 	return NULL;
+}
+
+/*! \brief Return the bridged channel of a Local channel */
+static struct ast_channel *local_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
+{
+	struct local_pvt *p = bridge->tech_pvt;
+	struct ast_channel *bridged = bridge;
+
+	ast_mutex_lock(&p->lock);
+
+	if (ast_test_flag(p, LOCAL_BRIDGE)) {
+		/* Find the opposite channel */
+		bridged = (bridge == p->owner ? p->chan : p->owner);
+		
+		/* Now see if the opposite channel is bridged to anything */
+		if (bridged->_bridge)
+			bridged = bridged->_bridge;
+	}
+
+	ast_mutex_unlock(&p->lock);
+
+	return bridged;
 }
 
 static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us)
@@ -601,6 +626,9 @@
 					"to use the 'j' option to enable the jitterbuffer\n");
 			}
 		}
+		if (strchr(opts, 'b')) {
+			ast_set_flag(tmp, LOCAL_BRIDGE);
+		}
 	}
 
 	/* Look for a context */

Modified: team/murf/bug11210/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_sip.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/channels/chan_sip.c (original)
+++ team/murf/bug11210/channels/chan_sip.c Fri Apr 11 16:18:56 2008
@@ -17606,7 +17606,7 @@
 				struct ast_channel *bridgepeer = NULL;
 				struct sip_pvt *bridgepvt = NULL;
 				if ((bridgepeer = ast_bridged_channel(p->owner))) {
-					if (IS_SIP_TECH(bridgepeer->tech)) {
+					if (IS_SIP_TECH(bridgepeer->tech) && !ast_check_hangup(bridgepeer)) {
 						bridgepvt = (struct sip_pvt*)bridgepeer->tech_pvt;
 						/* Does the bridged peer have T38 ? */
 						if (bridgepvt->t38.state == T38_ENABLED) {

Modified: team/murf/bug11210/contrib/scripts/astcli
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/contrib/scripts/astcli?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/contrib/scripts/astcli (original)
+++ team/murf/bug11210/contrib/scripts/astcli Fri Apr 11 16:18:56 2008
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Net::Telnet;
+use IO::Socket;
 use Getopt::Long;
 
 # Created by: David Van Ginneken
@@ -10,54 +10,104 @@
 #
 # And distributed under the terms of the GPL
 #
-my ($user, $pw, $host, $port) = (undef, undef, 'localhost', 5038);
+my ($user, $pw, $host, $port, $interactive, $save) = (undef, undef, 'localhost', 5038, 0, 0);
+my $EOL = "\r\n"; # Standard End of Line
+process_credentials('/etc/astcli.conf');
+process_credentials("$ENV{HOME}/.astcli") if defined $ENV{HOME};
+GetOptions("username=s" => \$user, "secret=s" => \$pw, "host=s" => \$host, "port=s" => \$port, "readline" => \$interactive, "write" => \$save);
 
-process_credentials('/etc/astcli.conf');
-process_credentials("$ENV{HOME}/.astcli");
-GetOptions("username=s" => \$user, "secret=s" => \$pw, "host=s" => \$host, "port=s" => \$port);
-
+$|++; # Auto Flush Output
 my $action = join(" ", @ARGV);
 
 &usage if (!defined $user || !defined $pw);
+my $tc = new IO::Socket::INET(
+		PeerAddr => $host,
+		PeerPort => $port,
+		Timeout => 30,
+		Proto => 'tcp'
+) or die "Could not connect to Host: $host on port $port\n";
+if (my $error = login()) {
+	print STDERR $error;
+	exit 1;
+};
 
-my $tc = new Net::Telnet (Timeout => 10,
-    Errmode => "die",
-    Host    => $host,
-    Port    => $port);
-# Login with our username and secret.
-$tc->open  ();
-$tc->print ("Action: Login");
-$tc->print ("Username: $user");
-$tc->print ("Secret: $pw");
-$tc->print ("Events: off");
-$tc->print (""); 
-# Check for login success.
-my ($pre, $match) = $tc->waitfor ("/Message: .*/");
-unless (($pre =~ m/Success/) && ($match =~ m/Authentication/)) {
-  print "Server Authentication failed.\n";
-  exit;
+if ($save) {
+	if (-d $ENV{HOME}) {
+		open DEFAULT, ">$ENV{HOME}/.astcli";
+		print DEFAULT "username=$user\n" if $user;
+		print DEFAULT "password=$pw\n" if $pw;
+		print DEFAULT "hostname=$host\n" if $host;
+		print DEFAULT "portno=$port\n" if $port;
+		close DEFAULT;
+	}
 }
 
 # Send a single command to the manager connection handle (global $tc).
 # Assumes things always work well :-)
 sub send_command($) {
 	my $command = shift;
+	$tc->send('Action: Command' . $EOL);
+	$tc->send("Command: $command" . $EOL);
+	$tc->send($EOL);
+	my $response = '';
+	while (<$tc>) {
+		last if $_ =~ /--END COMMAND--/;
+		$response .= $_;
+	}
+	$response =~ s/Privilege: Command$EOL//;
+	$response =~ s/Response: Follows$EOL//;
+	print $response;
+}
 
-	$tc->print ("Action: Command");
-	$tc->print ("Command: $command");
-	$tc->print ("");
-	my ($pre, undef) = $tc->waitfor ("/--END COMMAND--.*/");
-	$pre =~ s/^\n\n//g;
-	$pre =~ s/Privilege: Command\n//;
-	$pre =~ s/Response: Follows\n//;
-	print $pre;
+sub login {
+	my ($response, $message);
+	$tc->send("Action: Login" . $EOL);
+	$tc->send("Username: $user" . $EOL);
+	$tc->send("Secret: $pw" . $EOL);
+	$tc->send("Events: off" . $EOL);
+	$tc->send($EOL);
+	while (<$tc>) {
+		last if $_ eq $EOL;
+		$_ =~ s/$EOL//g;
+		($response) = $_ =~ /^Response: (.*?)$/ if $_ =~ /^Response:/;
+		($message) = $_ =~ /^Message: (.*?)$/ if $_ =~ /^Message:/;
+	}
+	return 0 if $response eq 'Success';
+	return $message;
+}
+
+sub logoff {
+	my ($response, $message);
+	$tc->send("Action: Logoff" . $EOL . $EOL);
+	return 1;
 }
 
 # If the user asked to send commands from standard input:
-if ($action eq '-') {
-	while (<>) {
-		chomp;
-		send_command($_)
+if ($action eq '-' || !defined $action || $action eq '') {
+	if ($interactive) {
+		eval { require Term::ReadLine;};
+		$interactive = scalar($@) ? 0 : 1;
+		print STDERR "Falling back to standard mode, Unable to load Term::Readline for readline mode\n" unless $interactive;
+	}
+	if ($interactive) {
+		my $term = new Term::ReadLine 'Command Line Interface';
+		my $prompt = "$host*CLI> ";
+		my $attribs = $term->Attribs;
+		$attribs->{completion_function} = sub {
+			my ($text, $line, $start) = @_;
+			# Stub function for tab auto completion for those feeling adventurous
+			return;
+		};
+		while (defined($_ = $term->readline($prompt))) {
+			(logoff() and exit) if $_ =~ /exit|quit/; # Give them a way to exit the "terminal"
+			send_command($_);
+		}	
+	} else {
+		while (<>) {
+			chomp;
+			(logoff() and exit) if $_ =~ /exit|quit/; # If someone accidentally ends up here, let them exit
+			send_command($_);
+		}
 	}
 	exit 0;
 }
@@ -69,7 +119,6 @@
 sub process_credentials {
 	# Process the credentials found..
 	my $file = shift;
-
 	# silently fail if we can't read the file:
 	return unless (-r $file);
 	open (my $fh, "<$file") or return;
@@ -84,8 +133,14 @@
 }
 
 sub usage {
-	print STDERR "astcli [-u <username> -s <passwd>] [-h host] [-p port] <cli-command>\n";
-	print STDERR "       (command '-' - take commands from input)\n";
+	print STDERR "astcli [<options>] [<cli-command>|-]\n";
+	print STDERR "       -u <name> - Connect as username <name>\n";
+	print STDERR "       -s <pw>   - Connect with secret <pw>\n";
+	print STDERR "       -h <host> - Connect to host <host> [localhost]\n";
+	print STDERR "       -p <port> - Connect on TCP port <port> [5038]\n";
+	print STDERR "       -r        - Start a readline session for interactivity\n";
+	print STDERR "       -w        - Save connection options in a configuration file\n";
+	print STDERR "   You may specify the command as '-' to take commands from stdin.\n";
 	exit;
 }
 

Modified: team/murf/bug11210/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/include/asterisk/lock.h?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/include/asterisk/lock.h (original)
+++ team/murf/bug11210/include/asterisk/lock.h Fri Apr 11 16:18:56 2008
@@ -148,18 +148,31 @@
  * lock info struct.  The lock is marked as pending as the thread is waiting
  * on the lock.  ast_mark_lock_acquired() will mark it as held by this thread.
  */
+#if !defined(LOW_MEMORY)
 void ast_store_lock_info(enum ast_lock_type type, const char *filename,
 	int line_num, const char *func, const char *lock_name, void *lock_addr);
+#else
+#define ast_store_lock_info(I,DONT,CARE,ABOUT,THE,PARAMETERS)
+#endif
+
 
 /*!
  * \brief Mark the last lock as acquired
  */
+#if !defined(LOW_MEMORY)
 void ast_mark_lock_acquired(void *lock_addr);
+#else
+#define ast_mark_lock_acquired(ignore)
+#endif
 
 /*!
  * \brief Mark the last lock as failed (trylock)
  */
+#if !defined(LOW_MEMORY)
 void ast_mark_lock_failed(void *lock_addr);
+#else
+#define ast_mark_lock_failed(ignore)
+#endif
 
 /*!
  * \brief remove lock info for the current thread
@@ -167,7 +180,11 @@
  * this gets called by ast_mutex_unlock so that information on the lock can
  * be removed from the current thread's lock info struct.
  */
+#if !defined(LOW_MEMORY)
 void ast_remove_lock_info(void *lock_addr);
+#else
+#define ast_remove_lock_info(ignore)
+#endif
 
 
 

Modified: team/murf/bug11210/main/features.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/main/features.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/main/features.c (original)
+++ team/murf/bug11210/main/features.c Fri Apr 11 16:18:56 2008
@@ -2098,6 +2098,7 @@
 	bridge_cdr = ast_cdr_alloc();
 	if (bridge_cdr) {
 		if (chan->cdr && peer->cdr) { /* both of them? merge */
+			ast_channel_lock(chan); /* lock the channel before modifying cdrs */
 			ast_cdr_init(bridge_cdr,chan); /* seems more logicaller to use the  destination as a base, but, really, it's random */
 			ast_cdr_start(bridge_cdr); /* now is the time to start */
 			
@@ -2106,14 +2107,22 @@
 			if (!ast_test_flag(chan->cdr, AST_CDR_FLAG_LOCKED))
 				ast_cdr_discard(chan->cdr); /* if locked cdrs are in chan, they are taken over in the merge */
 			
+			chan->cdr = NULL;
+			ast_channel_unlock(chan);
 			/* absorb the peer cdr */
+			ast_channel_lock(peer);
 			ast_cdr_merge(bridge_cdr, peer->cdr);
 			if (!ast_test_flag(peer->cdr, AST_CDR_FLAG_LOCKED))
 				ast_cdr_discard(peer->cdr); /* if locked cdrs are in peer, they are taken over in the merge */
 			
-			peer->cdr = NULL;
+			peer->cdr = NULL; /* remove pointer to freed memory before releasing the lock */
+			ast_channel_unlock(peer);
+
+			ast_channel_lock(chan);
 			chan->cdr = bridge_cdr; /* make this available to the rest of the world via the chan while the call is in progress */
+			ast_channel_unlock(chan);
 		} else if (chan->cdr) {
+			ast_channel_lock(chan); /* Lock before modifying CDR */
 			/* take the cdr from the channel - literally */
 			ast_cdr_init(bridge_cdr,chan);
 			/* absorb this data */
@@ -2121,7 +2130,9 @@
 			if (!ast_test_flag(chan->cdr, AST_CDR_FLAG_LOCKED))
 				ast_cdr_discard(chan->cdr); /* if locked cdrs are in chan, they are taken over in the merge */
 			chan->cdr = bridge_cdr; /* make this available to the rest of the world via the chan while the call is in progress */
+			ast_channel_unlock(chan);
 		} else if (peer->cdr) {
+			ast_channel_lock(peer); /* Lock before modifying CDR */
 			/* take the cdr from the peer - literally */
 			ast_cdr_init(bridge_cdr,peer);
 			/* absorb this data */
@@ -2130,10 +2141,13 @@
 				ast_cdr_discard(peer->cdr); /* if locked cdrs are in chan, they are taken over in the merge */
 			peer->cdr = NULL;
 			peer->cdr = bridge_cdr; /* make this available to the rest of the world via the chan while the call is in progress */
+			ast_channel_unlock(peer);
 		} else {
+			ast_channel_lock(chan); /* Lock before modifying CDR */
 			/* make up a new cdr */
 			ast_cdr_init(bridge_cdr,chan); /* eh, just pick one of them */
 			chan->cdr = bridge_cdr; /*  */
+			ast_channel_unlock(chan);
 		}
 		if (ast_strlen_zero(bridge_cdr->dstchannel)) {
 			if (strcmp(bridge_cdr->channel, peer->name) != 0)

Modified: team/murf/bug11210/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/main/manager.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/main/manager.c (original)
+++ team/murf/bug11210/main/manager.c Fri Apr 11 16:18:56 2008
@@ -2625,7 +2625,9 @@
 	const char *module = astman_get_header(m, "Module");
 	const char *id = astman_get_header(m, "ActionID");
 	char idText[256];
+#if !defined(LOW_MEMORY)
 	const char *version;
+#endif
 	char filename[PATH_MAX];
 	char *cut;
 
@@ -2644,14 +2646,18 @@
 	}
 	snprintf(cut, (sizeof(filename) - strlen(filename)) - 1, ".c");
 	ast_log(LOG_DEBUG, "**** ModuleCheck .c file %s\n", filename);
+#if !defined(LOW_MEMORY)
 	version = ast_file_version_find(filename);
+#endif
 
 	if (!ast_strlen_zero(id))
 		snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
 	else
 		idText[0] = '\0';
 	astman_append(s, "Response: Success\r\n%s", idText);
+#if !defined(LOW_MEMORY)
 	astman_append(s, "Version: %s\r\n\r\n", version ? version : "");
+#endif
 	return 0;
 }
 

Modified: team/murf/bug11210/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/main/utils.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/main/utils.c (original)
+++ team/murf/bug11210/main/utils.c Fri Apr 11 16:18:56 2008
@@ -1616,7 +1616,9 @@
 #endif
 	base64_init();
 #ifdef DEBUG_THREADS
+#if !defined(LOW_MEMORY)
 	ast_cli_register_multiple(utils_cli, sizeof(utils_cli) / sizeof(utils_cli[0]));
 #endif
+#endif
 	return 0;
 }

Modified: team/murf/bug11210/res/res_config_ldap.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/res/res_config_ldap.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/res/res_config_ldap.c (original)
+++ team/murf/bug11210/res/res_config_ldap.c Fri Apr 11 16:18:56 2008
@@ -552,7 +552,7 @@
 		do {
 			result = ldap_search_ext_s(ldapConn, dn, LDAP_SCOPE_BASE,
 					   "(objectclass=*)", NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &ldap_result);
-			if (result < 0 && is_ldap_connect_error(result)) {
+			if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
 				ast_log(LOG_WARNING,
 					"Failed to query database. Try %d/3\n",
 					tries + 1);
@@ -567,9 +567,9 @@
 						break;
 				}
 			}
-		} while (result < 0 && tries < 3 && is_ldap_connect_error(result));
-
-		if (result < 0) {
+		} while (result != LDAP_SUCCESS && tries < 3 && is_ldap_connect_error(result));
+
+		if (result != LDAP_SUCCESS) {
 			ast_log(LOG_WARNING,
 					"Failed to query database. Check debug for more info.\n");
 			ast_debug(2, "dn=%s\n", dn);
@@ -787,7 +787,7 @@
 		result = ldap_search_ext_s(ldapConn, clean_basedn,
 				  LDAP_SCOPE_SUBTREE, filter->str, NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT,
 				  &ldap_result);
-		if (result < 0 && is_ldap_connect_error(result)) {
+		if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
 			ast_log(LOG_DEBUG, "Failed to query database. Try %d/10\n",
 				tries + 1);
 			if (++tries < 10) {
@@ -800,9 +800,9 @@
 					break;
 			}
 		}
-	} while (result < 0 && tries < 10 && is_ldap_connect_error(result));
-
-	if (result < 0) {
+	} while (result != LDAP_SUCCESS && tries < 10 && is_ldap_connect_error(result));
+
+	if (result != LDAP_SUCCESS) {
 		ast_log(LOG_WARNING, "Failed to query database. Check debug for more info.\n");
 		ast_log(LOG_WARNING, "Query: %s\n", filter->str);
 		ast_log(LOG_WARNING, "Query Failed because: %s\n", ldap_err2string(result));
@@ -1244,7 +1244,7 @@
 		result = ldap_search_ext_s(ldapConn, clean_basedn,
 				  LDAP_SCOPE_SUBTREE, filter->str, NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT,
 				  &ldap_result);
-		if (result < 0 && is_ldap_connect_error(result)) {
+		if (result != LDAP_SUCCESS && is_ldap_connect_error(result)) {
 			ast_log(LOG_WARNING, "Failed to query database. Try %d/3\n",
 				tries + 1);
 			tries++;
@@ -1258,9 +1258,9 @@
 					break;
 			}
 		}
-	} while (result < 0 && tries < 3 && is_ldap_connect_error(result));
-
-	if (result < 0) {
+	} while (result != LDAP_SUCCESS && tries < 3 && is_ldap_connect_error(result));
+
+	if (result != LDAP_SUCCESS) {
 		ast_log(LOG_WARNING, "Failed to query directory. Check debug for more info.\n");
 		ast_log(LOG_WARNING, "Query: %s\n", filter->str);
 		ast_log(LOG_WARNING, "Query Failed because: %s\n",

Modified: team/murf/bug11210/res/res_phoneprov.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/res/res_phoneprov.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/res/res_phoneprov.c (original)
+++ team/murf/bug11210/res/res_phoneprov.c Fri Apr 11 16:18:56 2008
@@ -172,6 +172,7 @@
 
 /*! \brief List of global variables currently available: VOICEMAIL_EXTEN, EXTENSION_LENGTH */
 static struct varshead global_variables;
+static ast_mutex_t globals_lock;
 
 /*! \brief Return mime type based on extension */
 static char *ftype2mtype(const char *ftype)
@@ -665,12 +666,14 @@
 	/* Append the global variables to the variables list for this profile.
 	 * This is for convenience later, when we need to provide a single
 	 * variable list for use in substitution. */
+	ast_mutex_lock(&globals_lock);
 	AST_LIST_TRAVERSE(&global_variables, var, entries) {
 		struct ast_var_t *new_var;
 		if ((new_var = ast_var_assign(var->name, var->value))) {
 			AST_LIST_INSERT_TAIL(profile->headp, new_var, entries);
 		}
 	}
+	ast_mutex_unlock(&globals_lock);
 
 	ao2_link(profiles, profile);
 
@@ -890,10 +893,11 @@
 /* \brief Parse config files and create appropriate structures */
 static int set_config(void)
 {
-	struct ast_config *cfg;
+	struct ast_config *cfg, *phoneprov_cfg;
 	char *cat;
 	struct ast_variable *v;
 	struct ast_flags config_flags = { 0 };
+	struct ast_var_t *var;
 
 	/* Try to grab the port from sip.conf.  If we don't get it here, we'll set it
 	 * to whatever is set in phoneprov.conf or default to 5060 */
@@ -902,15 +906,37 @@
 		ast_config_destroy(cfg);
 	}
 
-	if (!(cfg = ast_config_load("phoneprov.conf", config_flags))) {
+	if (!(cfg = ast_config_load("users.conf", config_flags))) {
+		ast_log(LOG_WARNING, "Unable to load users.cfg\n");
+		return 0;
+	}
+
+	/* Go ahead and load global variables from users.conf so we can append to profiles */
+	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
+		if (!strcasecmp(v->name, "vmexten")) {
+			if ((var = ast_var_assign("VOICEMAIL_EXTEN", v->value))) {
+				ast_mutex_lock(&globals_lock);
+				AST_LIST_INSERT_TAIL(&global_variables, var, entries);
+				ast_mutex_unlock(&globals_lock);
+			}
+		}
+		if (!strcasecmp(v->name, "localextenlength")) {
+			if ((var = ast_var_assign("EXTENSION_LENGTH", v->value)))
+				ast_mutex_lock(&globals_lock);
+				AST_LIST_INSERT_TAIL(&global_variables, var, entries);
+				ast_mutex_unlock(&globals_lock);
+		}
+	}
+
+	if (!(phoneprov_cfg = ast_config_load("phoneprov.conf", config_flags))) {
 		ast_log(LOG_ERROR, "Unable to load config phoneprov.conf\n");
 		return -1;
 	}
 
 	cat = NULL;
-	while ((cat = ast_category_browse(cfg, cat))) {
+	while ((cat = ast_category_browse(phoneprov_cfg, cat))) {
 		if (!strcasecmp(cat, "general")) {
-			for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
+			for (v = ast_variable_browse(phoneprov_cfg, cat); v; v = v->next) {
 				if (!strcasecmp(v->name, "serveraddr"))
 					ast_copy_string(global_server, v->value, sizeof(global_server));
 				else if (!strcasecmp(v->name, "serveriface")) {
@@ -923,15 +949,10 @@
 					ast_copy_string(global_default_profile, v->value, sizeof(global_default_profile));
 			}
 		} else 
-			build_profile(cat, ast_variable_browse(cfg, cat));
-	}
-
-	ast_config_destroy(cfg);
-
-	if (!(cfg = ast_config_load("users.conf", config_flags))) {
-		ast_log(LOG_WARNING, "Unable to load users.cfg\n");
-		return 0;
-	}
+			build_profile(cat, ast_variable_browse(phoneprov_cfg, cat));
+	}
+
+	ast_config_destroy(phoneprov_cfg);
 
 	cat = NULL;
 	while ((cat = ast_category_browse(cfg, cat))) {
@@ -939,19 +960,9 @@
 		struct user *user;
 		struct phone_profile *profile;
 		struct extension *exten;
-		struct ast_var_t *var;
 
 		if (!strcasecmp(cat, "general")) {
-			for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
-				if (!strcasecmp(v->name, "vmexten")) {
-					if ((var = ast_var_assign("VOICEMAIL_EXTEN", v->value)))
-						AST_LIST_INSERT_TAIL(&global_variables, var, entries);
-				}
-				if (!strcasecmp(v->name, "localextenlength")) {
-					if ((var = ast_var_assign("EXTENSION_LENGTH", v->value)))
-						AST_LIST_INSERT_TAIL(&global_variables, var, entries);
-				}
-			}
+			continue;
 		}
 			  
 		if (!strcasecmp(cat, "authentication"))
@@ -970,7 +981,6 @@
 			ast_log(LOG_WARNING, "No profile for user [%s] with mac '%s' - skipping\n", cat, mac);
 			continue;
 		}
-
 
 		if (!(user = find_user(mac))) {
 			if (!(profile = find_profile(tmp))) {
@@ -1140,6 +1150,8 @@
 		ast_build_string(&buf, &len, "%s", expand_buf);
 	}
 
+	ast_free(file);
+
 	user = unref_user(user);
 
 	return 0;
@@ -1220,6 +1232,7 @@
 	users = ao2_container_alloc(MAX_USER_BUCKETS, users_hash_fn, users_cmp_fn);
 
 	AST_LIST_HEAD_INIT_NOLOCK(&global_variables);
+	ast_mutex_init(&globals_lock);
 	
 	ast_custom_function_register(&pp_each_user_function);
 	ast_custom_function_register(&pp_each_extension_function);
@@ -1247,17 +1260,31 @@
 	ao2_ref(http_routes, -1);
 	ao2_ref(users, -1);
 
-	while ((var = AST_LIST_REMOVE_HEAD(&global_variables, entries)))
+	ast_mutex_lock(&globals_lock);
+	while ((var = AST_LIST_REMOVE_HEAD(&global_variables, entries))) {
 		ast_var_delete(var);
+	}
+	ast_mutex_unlock(&globals_lock);
+
+	ast_mutex_destroy(&globals_lock);
 
 	return 0;
 }
 
 static int reload(void) 
 {
+	struct ast_var_t *var;
+
 	delete_routes();
 	delete_users();
 	delete_profiles();
+
+	ast_mutex_lock(&globals_lock);
+	while ((var = AST_LIST_REMOVE_HEAD(&global_variables, entries))) {
+		ast_var_delete(var);
+	}
+	ast_mutex_unlock(&globals_lock);
+
 	set_config();
 
 	return 0;

Modified: team/murf/bug11210/utils/Makefile
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/utils/Makefile?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/utils/Makefile (original)
+++ team/murf/bug11210/utils/Makefile Fri Apr 11 16:18:56 2008
@@ -80,7 +80,7 @@
 
 md5.c: $(ASTTOPDIR)/main/md5.c
 	@cp $< $@
-
+astman.o: astman.i
 astman: astman.o md5.o
 astman: LIBS+=$(NEWT_LIB)
 

Modified: team/murf/bug11210/utils/ael_main.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/utils/ael_main.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/utils/ael_main.c (original)
+++ team/murf/bug11210/utils/ael_main.c Fri Apr 11 16:18:56 2008
@@ -167,14 +167,17 @@
 	return 0; /* in "standalone" mode, functions are just not avail */
 }
 
+void ast_register_file_version(const char *file, const char *version);
 void ast_register_file_version(const char *file, const char *version)
 {
 }
 
+void ast_unregister_file_version(const char *file);
 void ast_unregister_file_version(const char *file)
 {
 }
 
+#if !defined(LOW_MEMORY)
 int ast_add_profile(const char *x, uint64_t scale)
 {
 	if (!no_comp)
@@ -182,6 +185,7 @@
 
 	return 0;
 }
+#endif
 
 int ast_loader_register(int (*updater)(void))
 {
@@ -600,7 +604,7 @@
 }
 
 #ifdef DEBUG_THREADS
-
+#if !defined(LOW_MEMORY)
 void ast_mark_lock_acquired(void *lock_addr)
 {
 }
@@ -613,5 +617,5 @@
 	int line_num, const char *func, const char *lock_name, void *lock_addr)
 {
 }
-
 #endif
+#endif

Modified: team/murf/bug11210/utils/astman.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/utils/astman.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/utils/astman.c (original)
+++ team/murf/bug11210/utils/astman.c Fri Apr 11 16:18:56 2008
@@ -92,6 +92,7 @@
 {
 }
 
+#if !defined(LOW_MEMORY)
 int ast_add_profile(const char *, uint64_t scale);
 int ast_add_profile(const char *s, uint64_t scale)
 {
@@ -108,6 +109,7 @@
 {
 	return 0;
 }
+#endif /* LOW_MEMORY */
 
 /* end of dummy functions */
 

Modified: team/murf/bug11210/utils/check_expr.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/utils/check_expr.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/utils/check_expr.c (original)
+++ team/murf/bug11210/utils/check_expr.c Fri Apr 11 16:18:56 2008
@@ -85,6 +85,7 @@
 	        AST_WRLOCK,
 };
 #endif
+#if !defined(LOW_MEMORY)
 void ast_store_lock_info(enum ast_lock_type type, const char *filename,
 		        int line_num, const char *func, const char *lock_name, void *lock_addr);
 void ast_store_lock_info(enum ast_lock_type type, const char *filename,
@@ -104,6 +105,7 @@
 {
     /* not a lot to do in a standalone w/o threading! */
 }
+#endif
 
 static int global_lineno = 1;
 static int global_expr_count=0;
@@ -145,9 +147,11 @@
 int check_eval(char *buffer, char *error_report);
 void parse_file(const char *fname);
 
+void ast_register_file_version(const char *file, const char *version);  
 void ast_register_file_version(const char *file, const char *version) { }
+#if !defined(LOW_MEMORY)
 int ast_add_profile(const char *x, uint64_t scale) { return 0;} 
-
+#endif
 int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
 {
         int ret;
@@ -156,6 +160,7 @@
         return ret;
 }
 
+void ast_unregister_file_version(const char *file);
 void ast_unregister_file_version(const char *file)
 {
 }

Modified: team/murf/bug11210/utils/conf2ael.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/utils/conf2ael.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/utils/conf2ael.c (original)
+++ team/murf/bug11210/utils/conf2ael.c Fri Apr 11 16:18:56 2008
@@ -78,15 +78,18 @@
 /* static AST_RWLIST_HEAD_STATIC(acf_root, ast_custom_function); */
 //extern char ast_config_AST_CONFIG_DIR[PATH_MAX];
 
+void ast_register_file_version(const char *file, const char *version);
 void ast_register_file_version(const char *file, const char *version)
 {
 }
 
+void ast_unregister_file_version(const char *file);
 void ast_unregister_file_version(const char *file)
 {
 }
+#if !defined(LOW_MEMORY)
 int ast_add_profile(const char *x, uint64_t scale) { return 0;}
-
+#endif
 /* Our own version of ast_log, since the expr parser uses it. -- stolen from utils/check_expr.c */
 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6)));
 
@@ -698,7 +701,7 @@
 }
 
 #ifdef DEBUG_THREADS
-
+#if !defined(LOW_MEMORY)
 void ast_mark_lock_acquired(void *lock_addr)
 {
 }
@@ -711,5 +714,5 @@
 	int line_num, const char *func, const char *lock_name, void *lock_addr)
 {
 }
-
 #endif
+#endif

Modified: team/murf/bug11210/utils/hashtest.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/utils/hashtest.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/utils/hashtest.c (original)
+++ team/murf/bug11210/utils/hashtest.c Fri Apr 11 16:18:56 2008
@@ -43,11 +43,12 @@
 int testno = 1;
 
 /* stuff we need to make this work with the hashtab stuff */
-
+#if !defined(LOW_MEMORY)
 int64_t ast_mark(int prof_id, int x)
 {
 	return 0;
 }
+#endif
 
 struct ht_element 
 {
@@ -299,11 +300,12 @@
 	
 	return 0;
 }
-
+#if !defined(LOW_MEMORY)
 int  ast_add_profile(const char *x, uint64_t scale)
 {
 	return 0;
 }
+#endif
 
 int ast_loader_register(int (*updater)(void))
 {
@@ -323,10 +325,12 @@
 }
 
 
+void ast_register_file_version(const char *file, const char *version);
 void ast_register_file_version(const char *file, const char *version)
 {
 }
 
+void ast_unregister_file_version(const char *file);
 void ast_unregister_file_version(const char *file)
 {
 

Modified: team/murf/bug11210/utils/hashtest2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/utils/hashtest2.c?view=diff&rev=114070&r1=114069&r2=114070
==============================================================================
--- team/murf/bug11210/utils/hashtest2.c (original)
+++ team/murf/bug11210/utils/hashtest2.c Fri Apr 11 16:18:56 2008
@@ -44,11 +44,12 @@
 int testno = 2;
 
 /* stuff we need to make this work with the astobj2 stuff */
-
+#if !defined(LOW_MEMORY)
 int64_t ast_mark(int prof_id, int x)
 {
 	return 0;
 }
+#endif
 
 /* my OBJECT */
 struct ht_element 
@@ -310,11 +311,12 @@
 	return 0;
 }
 
-
+#if !defined(LOW_MEMORY)
 int ast_add_profile(const char *x, uint64_t scale)
 {
 	return 0;
 }
+#endif
 
 int ast_loader_register(int (*updater)(void))
 {
@@ -334,10 +336,12 @@
 }
 
 
+void ast_register_file_version(const char *file, const char *version);
 void ast_register_file_version(const char *file, const char *version)
 {
 }
 
+void ast_unregister_file_version(const char *file);
 void ast_unregister_file_version(const char *file)
 {
 




More information about the asterisk-commits mailing list