made gethostbyaddr interruptable
authorClaus Gittinger <cg@exept.de>
Tue, 02 Jun 1998 20:28:20 +0200
changeset 650 8c5616f17ed6
parent 649 1bc56594db85
child 651 688ed6b56649
made gethostbyaddr interruptable
Socket.st
--- a/Socket.st	Thu May 28 15:19:09 1998 +0200
+++ b/Socket.st	Tue Jun 02 20:28:20 1998 +0200
@@ -393,6 +393,14 @@
 	    __END_INTERRUPTABLE__ \
 	} while ((hp == NULL) && \
 		 ((h_errno == TRY_AGAIN) || (errno == ECONNREFUSED)));
+
+# define GETHOSTBYADDR(hp, addr, alen, af) \
+        do { \
+	    __BEGIN_INTERRUPTABLE__ \
+	    hp = gethostbyaddr(addr, alen, af); \
+	    __END_INTERRUPTABLE__ \
+	} while ((hp == NULL) && \
+		((h_errno == TRY_AGAIN) || (errno == ECONNREFUSED)));
 #else
 # ifdef USE_H_ERRNO
 #  define GETHOSTBYNAME(hp, name) \
@@ -401,11 +409,23 @@
 	    hp = gethostbyname((char *) name); \
 	    __END_INTERRUPTABLE__ \
 	} while ((hp == NULL) && (h_errno == TRY_AGAIN));
+
+#  define GETHOSTBYADDR(hp, addr, alen, af) \
+	do { \
+	    __BEGIN_INTERRUPTABLE__  \
+	    hp = gethostbyaddr(addr, alen, af); \
+	    __END_INTERRUPTABLE__ \
+	} while ((hp == NULL) && (h_errno == TRY_AGAIN));
 # else
 #  define GETHOSTBYNAME(hp, name) \
 	__BEGIN_INTERRUPTABLE__  \
 	hp = gethostbyname((char *) name); \
 	__END_INTERRUPTABLE__ 
+
+#  define GETHOSTBYADDR(hp, addr, alen, af) \
+	__BEGIN_INTERRUPTABLE__ \
+	hp = gethostbyaddr(addr, alen, af); \
+	__END_INTERRUPTABLE__
 # endif
 #endif
 
@@ -1176,7 +1196,7 @@
 	sa.sat_family = AF_APPLETALK;
 
 	/* do we know the host's address? */
-	hp = gethostbyaddr((char *) &sa.sat_addr, sizeof(sa.sat_addr), AF_APPLETALK);
+	GETHOSTBYADDR(hp, (char *) &sa.sat_addr, sizeof(sa.sat_addr), AF_APPLETALK);
 	if (hp != NULL) {
 	    sa.sat_family = hp->h_addrtype;
 	} else {
@@ -1230,7 +1250,7 @@
 	sa.sin_addr.s_addr = htonl(sa.sin_addr.s_addr);    
 	sa.sin_family = AF_INET;
 	/* do we know the host's address? */
-	hp = gethostbyaddr((char *) &sa.sin_addr.s_addr, sizeof(sa.sin_addr.s_addr), AF_INET);
+	GETHOSTBYADDR(hp, (char *) &sa.sin_addr.s_addr, sizeof(sa.sin_addr.s_addr), AF_INET);
 	if (hp == NULL) {
 	    DBGPRINTF(("SOCKET: unknown address: %d.%d.%d.%d\n", 
 		       _intVal(b1), _intVal(b2), _intVal(b3), _intVal(b4)));
@@ -2802,7 +2822,7 @@
      */
 #ifdef AF_INET
     if (__INST(domain) == @symbol(inet)) {
-	he = gethostbyaddr((char *) &sa.in.sin_addr.s_addr, alen, AF_INET) ;
+	GETHOSTBYADDR(he, (char *) &sa.in.sin_addr.s_addr, alen, AF_INET);
 	if (! he) {
 	    unsigned long norder;
 
@@ -2821,7 +2841,7 @@
 
 #ifdef AF_INET6
     if (__INST(domain) == @symbol(inet6)) {
-	he = gethostbyaddr((char *) &sa.in6.sin6_addr.s6_addr, alen, AF_INET6) ;
+	GETHOSTBYADDR(he, (char *) &sa.in6.sin6_addr.s6_addr, alen, AF_INET6);
 	if (! he) {
 	    unsigned long norder;
 
@@ -2852,7 +2872,7 @@
 
 #ifdef AF_APPLETALK
     if (__INST(domain) == @symbol(appletalk)) {
-	he = gethostbyaddr((char *) &sa.at.sat_addr, alen, AF_APPLETALK) ;
+	GETHOSTBYADDR(he, (char *) &sa.at.sat_addr, alen, AF_APPLETALK);
 	if (! he) {
 	    unsigned net;
 
@@ -4097,5 +4117,5 @@
 !Socket class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.105 1998-05-28 13:19:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.106 1998-06-02 18:28:20 cg Exp $'
 ! !