[asterisk-commits] mmichelson: branch mmichelson/issue13538 r165810 - in /team/mmichelson/issue1...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 18 16:06:18 CST 2008


Author: mmichelson
Date: Thu Dec 18 16:06:17 2008
New Revision: 165810

URL: http://svn.digium.com/view/asterisk?view=rev&rev=165810
Log:
Get up to date with trunk


Modified:
    team/mmichelson/issue13538/   (props changed)
    team/mmichelson/issue13538/apps/app_queue.c
    team/mmichelson/issue13538/apps/app_voicemail.c
    team/mmichelson/issue13538/channels/chan_dahdi.c
    team/mmichelson/issue13538/channels/chan_misdn.c
    team/mmichelson/issue13538/channels/chan_oss.c
    team/mmichelson/issue13538/channels/chan_sip.c
    team/mmichelson/issue13538/main/manager.c
    team/mmichelson/issue13538/main/utils.c
    team/mmichelson/issue13538/pbx/pbx_ael.c

Propchange: team/mmichelson/issue13538/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/mmichelson/issue13538/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Dec 18 16:06:17 2008
@@ -1,1 +1,1 @@
-/trunk:1-165727
+/trunk:1-165809

Modified: team/mmichelson/issue13538/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue13538/apps/app_queue.c?view=diff&rev=165810&r1=165809&r2=165810
==============================================================================
--- team/mmichelson/issue13538/apps/app_queue.c (original)
+++ team/mmichelson/issue13538/apps/app_queue.c Thu Dec 18 16:06:17 2008
@@ -6439,9 +6439,9 @@
 		e->command = "queue {pause|unpause} member";
 		e->usage = 
 			"Usage: queue {pause|unpause} member <member> [queue <queue> [reason <reason>]]\n"
-			"		Pause or unpause a queue member. Not specifying a particular queue\n"
-			"		will pause or unpause a member across all queues to which the member\n"
-			"		belongs.\n";
+			"	Pause or unpause a queue member. Not specifying a particular queue\n"
+			"	will pause or unpause a member across all queues to which the member\n"
+			"	belongs.\n";
 		return NULL;
 	case CLI_GENERATE:
 		return complete_queue_pause_member(a->line, a-> word, a->pos, a->n);
@@ -6513,8 +6513,8 @@
 		e->command = "queue set penalty";
 		e->usage = 
 		"Usage: queue set penalty <penalty> on <interface> [in <queue>]\n"
-		"Set a member's penalty in the queue specified. If no queue is specified\n"
-		"then that interface's penalty is set in all queues to which that interface is a member\n";
+		"	Set a member's penalty in the queue specified. If no queue is specified\n"
+		"	then that interface's penalty is set in all queues to which that interface is a member\n";
 		return NULL;
 	case CLI_GENERATE:
 		return complete_queue_set_member_penalty(a->line, a->word, a->pos, a->n);
@@ -6575,8 +6575,8 @@
 		e->command = "queue show rules";
 		e->usage =
 		"Usage: queue show rules [rulename]\n"
-		"Show the list of rules associated with rulename. If no\n"
-		"rulename is specified, list all rules defined in queuerules.conf\n";
+		"	Show the list of rules associated with rulename. If no\n"
+		"	rulename is specified, list all rules defined in queuerules.conf\n";
 		return NULL;
 	case CLI_GENERATE:
 		return complete_queue_rule_show(a->line, a->word, a->pos, a->n);
@@ -6606,7 +6606,7 @@
 			e->command = "queue reload rules";
 			e->usage = 
 				"Usage: queue reload rules\n"
-				"Reloads rules defined in queuerules.conf\n";
+				"	Reloads rules defined in queuerules.conf\n";
 			return NULL;
 		case CLI_GENERATE:
 			return NULL;

Modified: team/mmichelson/issue13538/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue13538/apps/app_voicemail.c?view=diff&rev=165810&r1=165809&r2=165810
==============================================================================
--- team/mmichelson/issue13538/apps/app_voicemail.c (original)
+++ team/mmichelson/issue13538/apps/app_voicemail.c Thu Dec 18 16:06:17 2008
@@ -45,7 +45,7 @@
  ***/
 
 /*** MAKEOPTS
-<category name="MENUSELECT_OPTS_app_voicemail" displayname="Voicemail Build Options" positive_output="yes" remove_on_change="apps/app_voicemail.o apps/app_directory.o">
+<category name="MENUSELECT_OPTS_app_voicemail" displayname="Voicemail Build Options" positive_output="yes" remove_on_change="apps/app_voicemail.o apps/app_voicemail.so apps/app_directory.o apps/app_directory.so">
 	<member name="ODBC_STORAGE" displayname="Storage of Voicemail using ODBC">
 		<depend>odbc</depend>
 		<depend>ltdl</depend>
@@ -1462,7 +1462,9 @@
 		ast_log(LOG_DEBUG, "deleting msgnum %d, which is mailbox message %lu\n",msgnum,messageNum);
 	/* delete message */
 	snprintf (arg, sizeof(arg), "%lu",messageNum);
+	ast_mutex_lock(&vms->lock);
 	mail_setflag (vms->mailstream,arg,"\\DELETED");
+	ast_mutex_unlock(&vms->lock);
 }
 
 static int imap_retrieve_greeting (const char *dir, const int msgnum, struct ast_vm_user *vmu)
@@ -1496,10 +1498,12 @@
 	
 	/* Greetings will never have a prepended message */
 	*vms_p->introfn = '\0';
-	
+
+	ast_mutex_lock(&vms_p->lock);
 	ret = init_mailstream(vms_p, GREETINGS_FOLDER);
 	if (!vms_p->mailstream) {
 		ast_log(AST_LOG_ERROR, "IMAP mailstream is NULL\n");
+		ast_mutex_unlock(&vms_p->lock);
 		return -1;
 	}
 
@@ -1511,6 +1515,7 @@
 			attachment = ast_strdupa(body->nested.part->next->body.parameter->value);
 		} else {
 			ast_log(AST_LOG_ERROR, "There is no file attached to this IMAP message.\n");
+			ast_mutex_unlock(&vms_p->lock);
 			return -1;
 		}
 		filename = strsep(&attachment, ".");
@@ -1518,9 +1523,11 @@
 			ast_copy_string(vms_p->fn, dir, sizeof(vms_p->fn));
 			vms_p->msgArray[vms_p->curmsg] = i + 1;
 			save_body(body, vms_p, "2", attachment, 0);
+			ast_mutex_unlock(&vms_p->lock);
 			return 0;
 		}
 	}
+	ast_mutex_unlock(&vms_p->lock);
 
 	return -1;
 }
@@ -1586,7 +1593,9 @@
 	}
 
 	/* This will only work for new messages... */
+	ast_mutex_lock(&vms->lock);
 	header_content = mail_fetchheader (vms->mailstream, vms->msgArray[msgnum]);
+	ast_mutex_unlock(&vms->lock);
 	/* empty string means no valid header */
 	if (ast_strlen_zero(header_content)) {
 		ast_log (LOG_ERROR,"Could not fetch header for message number %ld\n",vms->msgArray[msgnum]);
@@ -1594,8 +1603,10 @@
 		goto exit;
 	}
 
+	ast_mutex_lock(&vms->lock);
 	mail_fetchstructure (vms->mailstream,vms->msgArray[msgnum],&body);
-	
+	ast_mutex_unlock(&vms->lock);
+
 	/* We have the body, now we extract the file name of the first attachment. */
 	if (body->nested.part && body->nested.part->next && body->nested.part->next->body.parameter->value) {
 		attachedfilefmt = ast_strdupa(body->nested.part->next->body.parameter->value);
@@ -1764,6 +1775,7 @@
 		return -1;
 	}
 	if (ret == 0) {
+		ast_mutex_lock(&vms_p->lock);
 		pgm = mail_newsearchpgm ();
 		hdr = mail_newsearchheader ("X-Asterisk-VM-Extension", (char *)mailbox);
 		pgm->header = hdr;
@@ -1796,10 +1808,13 @@
 			vms_p->urgentmessages = vms_p->vmArrayIndex;
 		/*Freeing the searchpgm also frees the searchhdr*/
 		mail_free_searchpgm(&pgm);
+		ast_mutex_unlock(&vms_p->lock);
 		vms_p->updated = 0;
 		return vms_p->vmArrayIndex;
-	} else {  
+	} else {
+		ast_mutex_lock(&vms_p->lock);
 		mail_ping(vms_p->mailstream);
+		ast_mutex_unlock(&vms_p->lock);
 	}
 	return 0;
 }
@@ -1897,8 +1912,10 @@
 	ret = init_mailstream(vms, NEW_FOLDER);
 	if (ret == 0) {
 		imap_mailbox_name(mailbox, sizeof(mailbox), vms, NEW_FOLDER, 1);
+		ast_mutex_lock(&vms->lock);
 		if(!mail_append_full(vms->mailstream, mailbox, imap_flags, NIL, &str))
 			ast_log(LOG_ERROR, "Error while sending the message to %s\n", mailbox);
+		ast_mutex_unlock(&vms->lock);
 		fclose(p);
 		unlink(tmp);
 		ast_free(buf);
@@ -2062,8 +2079,12 @@
 		return -1;
 	}
 	snprintf(messagestring, sizeof(messagestring), "%ld", sendvms->msgArray[msgnum]);
-	if ((mail_copy(sendvms->mailstream, messagestring, (char *) mbox(imbox)) == T))
+	ast_mutex_lock(&sendvms->lock);
+	if ((mail_copy(sendvms->mailstream, messagestring, (char *) mbox(imbox)) == T)) {
+		ast_mutex_unlock(&sendvms->lock);
 		return 0;
+	}
+	ast_mutex_unlock(&sendvms->lock);
 	ast_log(LOG_WARNING, "Unable to copy message from mailbox %s to mailbox %s\n", vmu->mailbox, recip->mailbox);
 	return -1;
 }
@@ -2199,6 +2220,7 @@
 		check_quota(vms,(char *)mbox(box));
 	}
 
+	ast_mutex_lock(&vms->lock);
 	pgm = mail_newsearchpgm();
 
 	/* Check IMAP folder for Asterisk messages only... */
@@ -2230,6 +2252,7 @@
 	vms->lastmsg = vms->vmArrayIndex - 1;
 	mail_free_searchpgm(&pgm);
 
+	ast_mutex_unlock(&vms->lock);
 	return 0;
 }
 
@@ -2238,9 +2261,9 @@
 	FILE *output;
 
 	output = fopen (filename, "w");
-	if (fwrite(buffer, len, 1, output) < len) {
+	if (fwrite(buffer, len, 1, output) != 1) {
 		if (ferror(output)) {
-			ast_log(LOG_ERROR, "Short write while writing e-mail body.\n");
+			ast_log(LOG_ERROR, "Short write while writing e-mail body: %s.\n", strerror(errno));
 		}
 	}
 	fclose (output);
@@ -2720,7 +2743,9 @@
 	if (!body || body == NIL)
 		return -1;
 
+	ast_mutex_lock(&vms->lock);
 	body_content = mail_fetchbody(vms->mailstream, vms->msgArray[vms->curmsg], section, &len);
+	ast_mutex_unlock(&vms->lock);
 	if (body_content != NIL) {
 		snprintf(filename, sizeof(filename), "%s.%s", fn, format);
 		/* ast_debug(1,body_content); */
@@ -2743,6 +2768,7 @@
  *
  * Determines the delimiter character that is used by the underlying IMAP based mail store.
  */
+/* MUTEX should already be held */
 static void get_mailbox_delimiter(MAILSTREAM *stream) {
 	char tmp[50];
 	snprintf(tmp, sizeof(tmp), "{%s}", imapserver);
@@ -2757,6 +2783,7 @@
  * Calls imap_getquotaroot, which will populate its results into the vm_state vms input structure.
  */
 static void check_quota(struct vm_state *vms, char *mailbox) {
+	ast_mutex_lock(&vms->lock);
 	mail_parameters(NULL, SET_QUOTA, (void *) mm_parsequota);
 	ast_debug(3, "Mailbox name set to: %s, about to check quotas\n", mailbox);
 	if (vms && vms->mailstream != NULL) {
@@ -2764,6 +2791,7 @@
 	} else {
 		ast_log(AST_LOG_WARNING, "Mailstream not available for mailbox: %s\n", mailbox);
 	}
+	ast_mutex_unlock(&vms->lock);
 }
 
 #endif /* IMAP_STORAGE */
@@ -5318,12 +5346,14 @@
 	/* expunge message - use UID Expunge if supported on IMAP server*/
 	ast_debug(3, "*** Checking if we can expunge, expungeonhangup set to %d\n",expungeonhangup);
 	if (expungeonhangup == 1) {
+		ast_mutex_lock(&vms->lock);
 #ifdef HAVE_IMAP_TK2006
 		if (LEVELUIDPLUS (vms->mailstream)) {
 			mail_expunge_full(vms->mailstream,NIL,EX_UID);
 		} else 
 #endif
 			mail_expunge(vms->mailstream);
+		ast_mutex_unlock(&vms->lock);
 	}
 #endif
 	
@@ -5344,17 +5374,22 @@
 	/* simple. huh? */
 	char sequence[10];
 	char mailbox[256];
+	int res;
+
 	/* get the real IMAP message number for this message */
 	snprintf(sequence, sizeof(sequence), "%ld", vms->msgArray[msg]);
 	
 	ast_debug(3, "Copying sequence %s to mailbox %s\n", sequence, mbox(box));
+	ast_mutex_lock(&vms->lock);
 	if (box == OLD_FOLDER) {
 		mail_setflag(vms->mailstream, sequence, "\\Seen");
 	} else if (box == NEW_FOLDER) {
 		mail_clearflag(vms->mailstream, sequence, "\\Seen");
 	}
-	if (!strcasecmp(mbox(NEW_FOLDER), vms->curbox) && (box == NEW_FOLDER || box == OLD_FOLDER))
+	if (!strcasecmp(mbox(NEW_FOLDER), vms->curbox) && (box == NEW_FOLDER || box == OLD_FOLDER)) {
+		ast_mutex_unlock(&vms->lock);
 		return 0;
+	}
 	/* Create the folder if it don't exist */
 	imap_mailbox_name(mailbox, sizeof(mailbox), vms, box, 1); /* Get the full mailbox name */
 	ast_debug(5, "Checking if folder exists: %s\n",mailbox);
@@ -5362,7 +5397,9 @@
 		ast_debug(5, "Folder exists.\n");
 	else
 		ast_log(AST_LOG_NOTICE, "Folder %s created!\n",mbox(box));
-	return !mail_copy(vms->mailstream, sequence, (char *)mbox(box));
+	res = !mail_copy(vms->mailstream, sequence, (char *)mbox(box));
+	ast_mutex_unlock(&vms->lock);
+	return res;
 #else
 	char *dir = vms->curdir;
 	char *username = vms->username;
@@ -6866,7 +6903,8 @@
 		ast_log(AST_LOG_ERROR, "Failed to procure file name from directory passed. You should never see this.\n");
 		return -1;
 	}
-	
+
+	ast_mutex_lock(&vms->lock);
 	for (i = 0; i < vms->mailstream->nmsgs; i++) {
 		mail_fetchstructure(vms->mailstream, i + 1, &body);
 		/* We have the body, now we extract the file name of the first attachment. */
@@ -6874,6 +6912,7 @@
 			attachment = ast_strdupa(body->nested.part->next->body.parameter->value);
 		} else {
 			ast_log(AST_LOG_ERROR, "There is no file attached to this IMAP message.\n");
+			ast_mutex_unlock(&vms->lock);
 			return -1;
 		}
 		filename = strsep(&attachment, ".");
@@ -6883,6 +6922,7 @@
 		}
 	}
 	mail_expunge(vms->mailstream);
+	ast_mutex_unlock(&vms->lock);
 	return 0;
 }
 
@@ -9439,12 +9479,14 @@
 	/* expunge message - use UID Expunge if supported on IMAP server*/
 	ast_debug(3, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup);
 	if (vmu && deleted == 1 && expungeonhangup == 1 && vms.mailstream != NULL) {
+		ast_mutex_lock(&vms.lock);
 #ifdef HAVE_IMAP_TK2006
 		if (LEVELUIDPLUS (vms.mailstream)) {
 			mail_expunge_full(vms.mailstream,NIL,EX_UID);
 		} else 
 #endif
 			mail_expunge(vms.mailstream);
+		ast_mutex_unlock(&vms.lock);
 	}
 	/*  before we delete the state, we should copy pertinent info
 	 *  back to the persistent model */

Modified: team/mmichelson/issue13538/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue13538/channels/chan_dahdi.c?view=diff&rev=165810&r1=165809&r2=165810
==============================================================================
--- team/mmichelson/issue13538/channels/chan_dahdi.c (original)
+++ team/mmichelson/issue13538/channels/chan_dahdi.c Thu Dec 18 16:06:17 2008
@@ -12030,7 +12030,9 @@
 	switch (cmd) {
 	case CLI_INIT:	
 		e->command = "pri show debug";
-		e->usage = "Show the debug state of pri spans\n";
+		e->usage = 
+			"Usage: pri show debug\n"
+			"	Show the debug state of pri spans\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;	
@@ -12064,7 +12066,9 @@
 	switch (cmd) {
 	case CLI_INIT:
 		e->command = "pri show version";
-		e->usage = "Show libpri version information\n";
+		e->usage = 
+			"Usage: pri show version\n"
+			"Show libpri version information\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
@@ -12888,10 +12892,10 @@
 		e->command = "dahdi set dnd";
 		e->usage = 
 			"Usage: dahdi set dnd <chan#> <on|off>\n"
-			"   Sets/resets DND (Do Not Disturb) mode on a channel.\n"
-			"   Changes take effect immediately.\n"
-			"   <chan num> is the channel number\n"
-			"   <on|off> Enable or disable DND mode?\n"
+			"	Sets/resets DND (Do Not Disturb) mode on a channel.\n"
+			"	Changes take effect immediately.\n"
+			"	<chan num> is the channel number\n"
+			" 	<on|off> Enable or disable DND mode?\n"
 			;
 		return NULL;
 	case CLI_GENERATE:
@@ -13572,7 +13576,9 @@
 	switch (cmd) {
 	case CLI_INIT:
 		e->command = "ss7 show version";
-		e->usage = "Show the libss7 version\n";
+		e->usage = 
+			"Usage: ss7 show version\n"
+			"	Show the libss7 version\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;

Modified: team/mmichelson/issue13538/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue13538/channels/chan_misdn.c?view=diff&rev=165810&r1=165809&r2=165810
==============================================================================
--- team/mmichelson/issue13538/channels/chan_misdn.c (original)
+++ team/mmichelson/issue13538/channels/chan_misdn.c Thu Dec 18 16:06:17 2008
@@ -996,7 +996,7 @@
 		e->command = "misdn show config";
 		e->usage =
 			"Usage: misdn show config [<port> | description <config element> | descriptions [general|ports]]\n"
-	        "       Use 0 for <port> to only print the general config.\n";
+		        "       Use 0 for <port> to only print the general config.\n";
 		return NULL;
 	case CLI_GENERATE:
 		return complete_show_config(a);

Modified: team/mmichelson/issue13538/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue13538/channels/chan_oss.c?view=diff&rev=165810&r1=165809&r2=165810
==============================================================================
--- team/mmichelson/issue13538/channels/chan_oss.c (original)
+++ team/mmichelson/issue13538/channels/chan_oss.c Thu Dec 18 16:06:17 2008
@@ -877,8 +877,9 @@
 	switch (cmd) {
 	case CLI_INIT:
 		e->command = CONSOLE_VIDEO_CMDS;
-		e->usage = "Usage: " CONSOLE_VIDEO_CMDS "...\n"
-		"       Generic handler for console commands.\n";
+		e->usage = 
+			"Usage: " CONSOLE_VIDEO_CMDS "...\n"
+			"       Generic handler for console commands.\n";
 		return NULL;
 
 	case CLI_GENERATE:

Modified: team/mmichelson/issue13538/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue13538/channels/chan_sip.c?view=diff&rev=165810&r1=165809&r2=165810
==============================================================================
--- team/mmichelson/issue13538/channels/chan_sip.c (original)
+++ team/mmichelson/issue13538/channels/chan_sip.c Thu Dec 18 16:06:17 2008
@@ -13673,9 +13673,9 @@
 	if (cmd == CLI_INIT) {
 		e->command = "sip prune realtime [peer|all]";
 		e->usage =
-		"Usage: sip prune realtime [peer [<name>|all|like <pattern>]|all]\n"
-		"       Prunes object(s) from the cache.\n"
-		"       Optional regular expression pattern is used to filter the objects.\n";
+			"Usage: sip prune realtime [peer [<name>|all|like <pattern>]|all]\n"
+			"       Prunes object(s) from the cache.\n"
+			"       Optional regular expression pattern is used to filter the objects.\n";
 		return NULL;
 	} else if (cmd == CLI_GENERATE) {
 		if (a->pos == 4 && !strcasecmp(a->argv[3], "peer")) {
@@ -14745,10 +14745,10 @@
 	if (cmd == CLI_INIT) {
 		e->command = "sip show {channels|subscriptions}";
 		e->usage =
-		"Usage: sip show channels\n"
-		"       Lists all currently active SIP calls (dialogs).\n"
-		"Usage: sip show subscriptions\n"
-		"       Lists active SIP subscriptions.\n";
+			"Usage: sip show channels\n"
+			"       Lists all currently active SIP calls (dialogs).\n"
+			"Usage: sip show subscriptions\n"
+			"       Lists active SIP subscriptions.\n";
 		return NULL;
 	} else if (cmd == CLI_GENERATE)
 		return NULL;
@@ -15463,7 +15463,7 @@
 	case CLI_INIT:
 		e->command = "sip set history {on|off}";
 		e->usage =
-			"Usage: sip history {on|off}\n"
+			"Usage: sip set history {on|off}\n"
 			"       Enables/Disables recording of SIP dialog history for debugging purposes.\n"
 			"       Use 'sip show history' to view the history of a call number.\n";
 		return NULL;

Modified: team/mmichelson/issue13538/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue13538/main/manager.c?view=diff&rev=165810&r1=165809&r2=165810
==============================================================================
--- team/mmichelson/issue13538/main/manager.c (original)
+++ team/mmichelson/issue13538/main/manager.c Thu Dec 18 16:06:17 2008
@@ -1109,9 +1109,13 @@
 
 static int action_ping(struct mansession *s, const struct message *m)
 {
-	astman_append(s, "Response: Success\r\n"
-		"Ping: Pong\r\n"
-		"\r\n");
+	const char *actionid = astman_get_header(m, "ActionID");
+
+	astman_append(s, "Response: Success\r\n");
+	if (!ast_strlen_zero(actionid)){
+		astman_append(s, "ActionID: %s\r\n", actionid);
+	}
+	astman_append(s, "Ping: Pong\r\n\r\n");
 	return 0;
 }
 

Modified: team/mmichelson/issue13538/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue13538/main/utils.c?view=diff&rev=165810&r1=165809&r2=165810
==============================================================================
--- team/mmichelson/issue13538/main/utils.c (original)
+++ team/mmichelson/issue13538/main/utils.c Thu Dec 18 16:06:17 2008
@@ -1074,29 +1074,54 @@
  */
 int ast_carefulwrite(int fd, char *s, int len, int timeoutms) 
 {
-	/* Try to write string, but wait no more than ms milliseconds
-	   before timing out */
 	int res = 0;
-	struct pollfd fds[1];
+
 	while (len) {
+		struct pollfd pfd = {
+			.fd = fd,
+			.events = POLLOUT,
+		};
+
+		/* poll() until the fd is writable without blocking */
+		while ((res = poll(&pfd, 1, timeoutms)) <= 0) {
+			if (res == 0) {
+				/* timed out. */
+				ast_log(LOG_NOTICE, "Timed out trying to write\n");
+				return -1;
+			} else if (res == -1) {
+				/* poll() returned an error, check to see if it was fatal */
+
+				if (errno == EINTR || errno == EAGAIN) {
+					/* This was an acceptable error, go back into poll() */
+					continue;
+				}
+
+				/* Fatal error, bail. */
+				ast_log(LOG_ERROR, "poll returned error: %s\n", strerror(errno));
+
+				return -1;
+			}
+		}
+
 		res = write(fd, s, len);
-		if ((res < 0) && (errno != EAGAIN)) {
+
+		if (res < 0 && errno != EAGAIN && errno != EINTR) {
+			/* fatal error from write() */
+			ast_log(LOG_ERROR, "write() returned error: %s\n", strerror(errno));
 			return -1;
 		}
-		if (res < 0)
+
+		if (res < 0) {
+			/* It was an acceptable error */
 			res = 0;
+		}
+
+		/* Update how much data we have left to write */
 		len -= res;
 		s += res;
 		res = 0;
-		if (len) {
-			fds[0].fd = fd;
-			fds[0].events = POLLOUT;
-			/* Wait until writable again */
-			res = poll(fds, 1, timeoutms);
-			if (res < 1)
-				return -1;
-		}
-	}
+	}
+
 	return res;
 }
 

Modified: team/mmichelson/issue13538/pbx/pbx_ael.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/issue13538/pbx/pbx_ael.c?view=diff&rev=165810&r1=165809&r2=165810
==============================================================================
--- team/mmichelson/issue13538/pbx/pbx_ael.c (original)
+++ team/mmichelson/issue13538/pbx/pbx_ael.c Thu Dec 18 16:06:17 2008
@@ -164,7 +164,7 @@
 	case CLI_INIT:
 		e->command = "ael set debug {read|tokens|macros|contexts|off}";
 		e->usage =
-			"Usage: ael debug {read|tokens|macros|contexts|off}\n"
+			"Usage: ael set debug {read|tokens|macros|contexts|off}\n"
 			"       Enable AEL read, token, macro, or context debugging,\n"
 			"       or disable all AEL debugging messages.  Note: this\n"
 			"       currently does nothing.\n";




More information about the asterisk-commits mailing list