[asterisk-commits] trunk r25026 - in /trunk: ./ include/asterisk/ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon May 8 04:11:03 MST 2006


Author: russell
Date: Fri May  5 16:01:39 2006
New Revision: 25026

URL: http://svn.digium.com/view/asterisk?rev=25026&view=rev
Log:
move ast_carefulwrite from manager.c to utils.c so that cli.c and
res_agi.c no longer depend on manager.h (issue #6397, casper)

Modified:
    trunk/cli.c
    trunk/include/asterisk/manager.h
    trunk/include/asterisk/utils.h
    trunk/manager.c
    trunk/res/res_agi.c
    trunk/utils.c

Modified: trunk/cli.c
URL: http://svn.digium.com/view/asterisk/trunk/cli.c?rev=25026&r1=25025&r2=25026&view=diff
==============================================================================
--- trunk/cli.c (original)
+++ trunk/cli.c Fri May  5 16:01:39 2006
@@ -44,7 +44,6 @@
 #include "asterisk/module.h"
 #include "asterisk/pbx.h"
 #include "asterisk/channel.h"
-#include "asterisk/manager.h"
 #include "asterisk/utils.h"
 #include "asterisk/app.h"
 #include "asterisk/lock.h"

Modified: trunk/include/asterisk/manager.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/manager.h?rev=25026&r1=25025&r2=25026&view=diff
==============================================================================
--- trunk/include/asterisk/manager.h (original)
+++ trunk/include/asterisk/manager.h Fri May  5 16:01:39 2006
@@ -81,8 +81,6 @@
 	struct manager_action *next;
 };
 
-int ast_carefulwrite(int fd, char *s, int len, int timeoutms);
-
 /* External routines may register/unregister manager callbacks this way */
 #define ast_manager_register(a, b, c, d) ast_manager_register2(a, b, c, d, NULL)
 

Modified: trunk/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/utils.h?rev=25026&r1=25025&r2=25026&view=diff
==============================================================================
--- trunk/include/asterisk/utils.h (original)
+++ trunk/include/asterisk/utils.h Fri May  5 16:01:39 2006
@@ -217,6 +217,17 @@
 int ast_utils_init(void);
 int ast_wait_for_input(int fd, int ms);
 
+/*! ast_carefulwrite
+	\brief Try to write string, but wait no more than ms milliseconds
+	before timing out.
+
+	\note If you are calling ast_carefulwrite, it is assumed that you are calling
+	it on a file descriptor that _DOES_ have NONBLOCK set.  This way,
+	there is only one system call made to do a write, unless we actually
+	have a need to wait.  This way, we get better performance.
+*/
+int ast_carefulwrite(int fd, char *s, int len, int timeoutms);
+
 /*! Compares the source address and port of two sockaddr_in */
 static force_inline int inaddrcmp(const struct sockaddr_in *sin1, const struct sockaddr_in *sin2)
 {

Modified: trunk/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/manager.c?rev=25026&r1=25025&r2=25026&view=diff
==============================================================================
--- trunk/manager.c (original)
+++ trunk/manager.c Fri May  5 16:01:39 2006
@@ -167,38 +167,6 @@
 
 static struct manager_action *first_action = NULL;
 AST_MUTEX_DEFINE_STATIC(actionlock);
-
-/*! If you are calling ast_carefulwrite, it is assumed that you are calling
-   it on a file descriptor that _DOES_ have NONBLOCK set.  This way,
-   there is only one system call made to do a write, unless we actually
-   have a need to wait.  This way, we get better performance. */
-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) {
-		res = write(fd, s, len);
-		if ((res < 0) && (errno != EAGAIN)) {
-			return -1;
-		}
-		if (res < 0)
-			res = 0;
-		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;
-}
 
 /*! authority_to_str: Convert authority code to string with serveral options */
 static char *authority_to_str(int authority, char *res, int reslen)

Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?rev=25026&r1=25025&r2=25026&view=diff
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Fri May  5 16:01:39 2006
@@ -59,7 +59,6 @@
 #include "asterisk/app.h"
 #include "asterisk/dsp.h"
 #include "asterisk/musiconhold.h"
-#include "asterisk/manager.h"
 #include "asterisk/utils.h"
 #include "asterisk/lock.h"
 #include "asterisk/strings.h"

Modified: trunk/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/utils.c?rev=25026&r1=25025&r2=25026&view=diff
==============================================================================
--- trunk/utils.c (original)
+++ trunk/utils.c Fri May  5 16:01:39 2006
@@ -589,6 +589,34 @@
 	pfd[0].fd = fd;
 	pfd[0].events = POLLIN|POLLPRI;
 	return poll(pfd, 1, ms);
+}
+
+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) {
+		res = write(fd, s, len);
+		if ((res < 0) && (errno != EAGAIN)) {
+			return -1;
+		}
+		if (res < 0)
+			res = 0;
+		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;
 }
 
 char *ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)



More information about the asterisk-commits mailing list