commit - b0003f5861f022ca86f3b254ebb0c3f2fdadfe4e
commit + 723bee54d360957eec85ac2eef9ebd5516db3ade
blob - b9d7b8287a090c303ff1b6a8df20342f17075afb
blob + a1c257215f7f6c1e9d123d4250f34403415a94e1
--- gemini.c
+++ gemini.c
static void handle_stop(struct imsg*, size_t);
static void handle_quit(struct imsg*, size_t);
+/* TODO: making this customizable */
+struct timeval timeout_for_handshake = { 5, 0 };
+
static imsg_handlerfn *handlers[] = {
[IMSG_GET] = handle_get,
[IMSG_CERT_STATUS] = handle_cert_status,
struct req *req = d;
const char *hash;
+ if (ev == EV_TIMEOUT) {
+ close_with_err(req, "Timeout loading page");
+ return;
+ }
+
switch (tls_handshake(req->ctx)) {
case TLS_WANT_POLLIN:
yield_r(req, do_handshake, NULL);
req->buf, len);
imsg_flush(ibuf);
+ if (code != 20)
+ close_conn(0, 0, req);
+
return;
err:
}
TAILQ_INSERT_HEAD(&reqhead, req, reqs);
- yield_w(req, do_handshake, NULL);
+ yield_w(req, do_handshake, &timeout_for_handshake);
return;
err:
if ((n = imsg_read(ibuf)) == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK)
return;
- die();
+ _exit(1);
}
if (n == 0)
- die();
+ _exit(1);
for (;;) {
if ((n = imsg_get(ibuf, &imsg)) == -1)
- die();
+ _exit(1);
if (n == 0)
return;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;