Introduction
Introduction Statistics Contact Development Disclaimer Help
add alarm timer in case connection hangs without triggering a connect timeout -…
git clone git://git.codemadness.org/hurl
Log
Files
Refs
README
LICENSE
---
commit e5399e327f21a6033de0decb3c8588a17a63eea8
parent e0b2498d20b2082339ac02a098b40a11bdbe3ab7
Author: Hiltjo Posthuma <[email protected]>
Date: Fri, 22 May 2020 21:32:48 +0200
add alarm timer in case connection hangs without triggering a connect timeout
Noticed on a (broken?) snapshot version on OpenBSD -current with libtls.
Should make the time-out behaviour more reliable regardless.
Diffstat:
M hurl.c | 12 ++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/hurl.c b/hurl.c
@@ -6,6 +6,7 @@
#include <errno.h>
#include <netdb.h>
#include <locale.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
@@ -54,6 +55,13 @@ static char *url;
/* TLS config */
static struct tls_config *tls_config;
+void
+sighandler(int signo)
+{
+ if (signo == SIGALRM)
+ _exit(2);
+}
+
int
parseuri(const char *s, struct uri *u)
{
@@ -525,6 +533,10 @@ main(int argc, char **argv)
if (parseuri(url, &u) == -1)
errx(1, "invalid url: %s", url);
+ signal(SIGALRM, sighandler);
+ if (alarm(config_timeout) == -1)
+ err(1, "alarm");
+
if (!strcmp(u.proto, "https")) {
if (tls_init())
errx(1, "tls_init failed");
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.