--- lib/hostip.c~	2002-10-01 10:40:15.000000000 +0200
+++ lib/hostip.c	2002-10-21 14:47:42.000000000 +0200
@@ -597,14 +597,20 @@
 #endif
 #ifdef HAVE_GETHOSTBYNAME_R_6
     /* Linux */
-    while((res=gethostbyname_r(hostname,
-                               (struct hostent *)buf,
-                               (char *)buf + sizeof(struct hostent),
-                               step_size - sizeof(struct hostent),
-                               &h, /* DIFFERENCE */
-                               &h_errnop))==ERANGE) {
-      step_size+=200;
-    }
+    do {
+      res=gethostbyname_r(hostname,
+			  (struct hostent *)buf,
+			  (char *)buf + sizeof(struct hostent),
+			  step_size - sizeof(struct hostent),
+			  &h, /* DIFFERENCE */
+			  &h_errnop);
+      if((ERANGE == res) || (EAGAIN == res)) {
+	step_size+=200;
+	continue;
+      }
+      break;
+    } while(1);
+
     if(!h) /* failure */
       res=1;
     
