diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2006-08-14 01:28:47 +0000 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2006-08-14 01:28:47 +0000 |
commit | df4a264f6a4bf53592f9e273462a8861ea7e6a6d (patch) | |
tree | 7fc180164f8bc204cea413b098a9068dbdc2c792 /fm_getaddrinfo.c | |
parent | c625d7a00b024fe5de26d16b6420abebb1db705c (diff) | |
download | fetchmail-df4a264f6a4bf53592f9e273462a8861ea7e6a6d.tar.gz fetchmail-df4a264f6a4bf53592f9e273462a8861ea7e6a6d.tar.bz2 fetchmail-df4a264f6a4bf53592f9e273462a8861ea7e6a6d.zip |
Wrap getaddrinfo() and block SIGALRM where needed.
Also wrap freeaddrinfo() without added functionality.
svn path=/branches/BRANCH_6-3/; revision=4895
Diffstat (limited to 'fm_getaddrinfo.c')
-rw-r--r-- | fm_getaddrinfo.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/fm_getaddrinfo.c b/fm_getaddrinfo.c new file mode 100644 index 00000000..97cec65c --- /dev/null +++ b/fm_getaddrinfo.c @@ -0,0 +1,40 @@ +#include "config.h" +#include "fetchmail.h" +#include "i18n.h" + +#include <signal.h> +#include <errno.h> +#include <string.h> + +/** This is a getaddrinfo() replacement that blocks SIGALRM, + * to avoid issues with non-reentrant getaddrinfo() implementations + * after SIGALRM timeouts, for instance on MacOS X or NetBSD. */ +int fm_getaddrinfo(const char *node, const char *serv, const struct addrinfo *hints, struct addrinfo **res) +{ + int rc; + +#ifndef GETADDRINFO_ASYNCSAFE + sigset_t ss, os; + + sigemptyset(&ss); + sigaddset(&ss, SIGALRM); + + if (sigprocmask(SIG_BLOCK, &ss, &os)) + report(stderr, GT_("Cannot modify signal mask: %s"), strerror(errno)); +#endif + + rc = getaddrinfo(node, serv, hints, res); + +#ifndef GETADDRINFO_ASYNCSAFE + if (sigprocmask(SIG_SETMASK, &os, NULL)) + report(stderr, GT_("Cannot modify signal mask: %s"), strerror(errno)); +#endif + + return rc; +} + +/** this is a debugging freeaddrinfo() wrapper. */ +void fm_freeaddrinfo(struct addrinfo *ai) +{ + freeaddrinfo(ai); +} |