This file looks large and may slow your browser down if we attempt
to syntax highlight it, so we are showing it without any
pretty colors.
Highlight
it anyway.
| 1 |
#include "config.h" |
| 2 |
#include "fetchmail.h" |
| 3 |
#include "i18n.h" |
| 4 |
|
| 5 |
#include <signal.h> |
| 6 |
#include <errno.h> |
| 7 |
#include <string.h> |
| 8 |
|
| 9 |
/** This is a getaddrinfo() replacement that blocks SIGALRM, |
| 10 |
* to avoid issues with non-reentrant getaddrinfo() implementations |
| 11 |
* after SIGALRM timeouts, for instance on MacOS X or NetBSD. */ |
| 12 |
int fm_getaddrinfo(const char *node, const char *serv, const struct addrinfo *hints, struct addrinfo **res) |
| 13 |
{ |
| 14 |
int rc; |
| 15 |
|
| 16 |
#ifndef GETADDRINFO_ASYNCSAFE |
| 17 |
sigset_t ss, os; |
| 18 |
|
| 19 |
sigemptyset(&ss); |
| 20 |
sigaddset(&ss, SIGALRM); |
| 21 |
|
| 22 |
if (sigprocmask(SIG_BLOCK, &ss, &os)) |
| 23 |
report(stderr, GT_("Cannot modify signal mask: %s"), strerror(errno)); |
| 24 |
#endif |
| 25 |
|
| 26 |
rc = getaddrinfo(node, serv, hints, res); |
| 27 |
|
| 28 |
#ifndef GETADDRINFO_ASYNCSAFE |
| 29 |
if (sigprocmask(SIG_SETMASK, &os, NULL)) |
| 30 |
report(stderr, GT_("Cannot modify signal mask: %s"), strerror(errno)); |
| 31 |
#endif |
| 32 |
|
| 33 |
return rc; |
| 34 |
} |
| 35 |
|
| 36 |
/** this is a debugging freeaddrinfo() wrapper. */ |
| 37 |
void fm_freeaddrinfo(struct addrinfo *ai) |
| 38 |
{ |
| 39 |
freeaddrinfo(ai); |
| 40 |
} |