[Asterisk-cvs] asterisk acl.c,1.16,1.17 asterisk.c,1.68,1.69

markster at lists.digium.com markster at lists.digium.com
Wed Apr 21 20:15:52 CDT 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv19986

Modified Files:
	acl.c asterisk.c 
Log Message:
gethostbyname isn't reentrant, who knew...


Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- acl.c	20 Mar 2004 19:08:57 -0000	1.16
+++ acl.c	22 Apr 2004 00:20:33 -0000	1.17
@@ -139,7 +139,8 @@
 int ast_get_ip(struct sockaddr_in *sin, char *value)
 {
 	struct hostent *hp;
-	hp = gethostbyname(value);
+	struct ast_hostent ahp;
+	hp = ast_gethostbyname(value, &ahp);
 	if (hp) {
 		memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
 	} else {

Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- asterisk.c	9 Apr 2004 17:46:04 -0000	1.68
+++ asterisk.c	22 Apr 2004 00:20:33 -0000	1.69
@@ -46,6 +46,7 @@
 #include "editline/histedit.h"
 #include "asterisk.h"
 #include <asterisk/config.h>
+#include <asterisk/lock.h>
 
 #define AST_MAX_CONNECTS 128
 #define NUM_MSGS 64
@@ -1674,4 +1675,16 @@
 		ast_select(0,NULL,NULL,NULL,NULL);
 	}
 	return 0;
+}
+
+struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp)
+{
+	int res;
+	int h_errno;
+	struct hostent *result = NULL;
+	/* XXX Does BSD do this differently? XXX */
+	res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &result, &h_errno);
+	if (res)
+		return NULL;
+	return &hp->hp;
 }




More information about the svn-commits mailing list