+2002-04-15 Ian Abbott <abbotti@mev.co.uk>
+
+ * host.c (SET_H_ERRNO): New function-like macro to set `h_errno'.
+ (gethostbyname_with_timeout): Use it.
+
+ * utils.c: Don't define `SETJMP()', `run_with_timeout_env' or
+ `abort_run_with_timeout()' when `USE_SIGNAL_TIMEOUT' is undefined.
+
2002-04-15 Hrvoje Niksic <hniksic@arsdigita.com>
* host.c (getaddrinfo_with_timeout): New function.
#ifdef WINDOWS
# include <winsock.h>
+# define SET_H_ERRNO(err) WSASetLastError(err)
#else
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# endif
# include <netdb.h>
+# define SET_H_ERRNO(err) ((void)(h_errno = (err)))
#endif /* WINDOWS */
#ifndef NO_ADDRESS
ctx.host_name = host_name;
if (run_with_timeout (timeout, gethostbyname_with_timeout_callback, &ctx))
{
- h_errno = HOST_NOT_FOUND;
+ SET_H_ERRNO (HOST_NOT_FOUND);
errno = ETIMEDOUT;
return NULL;
}
\f
/* Implementation of run_with_timeout, a generic timeout handler for
systems with Unix-like signal handling. */
-#ifdef HAVE_SIGSETJMP
-#define SETJMP(env) sigsetjmp (env, 1)
+#ifdef USE_SIGNAL_TIMEOUT
+# ifdef HAVE_SIGSETJMP
+# define SETJMP(env) sigsetjmp (env, 1)
static sigjmp_buf run_with_timeout_env;
assert (sig == SIGALRM);
siglongjmp (run_with_timeout_env, -1);
}
-#else /* not HAVE_SIGSETJMP */
-#define SETJMP(env) setjmp (env)
+# else /* not HAVE_SIGSETJMP */
+# define SETJMP(env) setjmp (env)
static jmp_buf run_with_timeout_env;
/* Now it's safe to longjump. */
longjmp (run_with_timeout_env, -1);
}
-#endif /* not HAVE_SIGSETJMP */
+# endif /* not HAVE_SIGSETJMP */
+#endif /* USE_SIGNAL_TIMEOUT */
int
run_with_timeout (long timeout, void (*fun) (void *), void *arg)