Commit 29d3ded7 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

cddb: do not use alarm()

It does not work on Windows, and is not thread-safe on Linux.
parent 1193208c
diff -ru cddb.orig/lib/cddb_net.c cddb/lib/cddb_net.c
--- cddb.orig/lib/cddb_net.c 2011-11-05 18:21:42.000000000 +0200
+++ cddb/lib/cddb_net.c 2011-11-05 18:22:11.000000000 +0200
@@ -228,46 +228,9 @@
/* Time-out enabled work-alikes */
-#ifdef HAVE_ALARM
-/* time-out jump buffer */
-static jmp_buf timeout_expired;
-
-/* time-out signal handler */
-static void alarm_handler(int signum)
-{
- longjmp(timeout_expired, 1);
-}
-#endif
-
struct hostent *timeout_gethostbyname(const char *hostname, int timeout)
{
-#ifdef HAVE_ALARM
- struct hostent *he = NULL;
- struct sigaction action;
- struct sigaction old;
-
- /* no signal before setjmp */
- alarm(0);
-
- /* register signal handler */
- memset(&action, 0, sizeof(action));
- action.sa_handler = alarm_handler;
- sigaction(SIGALRM, &action, &old);
-
- /* save stack state */
- if (!setjmp(timeout_expired)) {
- alarm(timeout); /* set time-out alarm */
- he = gethostbyname(hostname); /* execute DNS query */
- alarm(0); /* reset alarm timer */
- } else {
- errno = ETIMEDOUT;
- }
- sigaction(SIGALRM, &old, NULL); /* restore previous signal handler */
-
- return he;
-#else
return gethostbyname(hostname); /* execute DNS query directly */
-#endif
}
int timeout_connect(int sockfd, const struct sockaddr *addr,
...@@ -18,6 +18,7 @@ cddb: libcddb-$(CDDB_VERSION).tar.bz2 .sum-cddb ...@@ -18,6 +18,7 @@ cddb: libcddb-$(CDDB_VERSION).tar.bz2 .sum-cddb
$(UNPACK) $(UNPACK)
$(APPLY) $(SRC)/cddb/cross.patch $(APPLY) $(SRC)/cddb/cross.patch
$(APPLY) $(SRC)/cddb/getenv-crash.patch $(APPLY) $(SRC)/cddb/getenv-crash.patch
$(APPLY) $(SRC)/cddb/cddb-no-alarm.patch
ifdef HAVE_WIN32 ifdef HAVE_WIN32
$(APPLY) $(SRC)/cddb/win32-pkg.patch $(APPLY) $(SRC)/cddb/win32-pkg.patch
endif endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment