Module Name: src Committed By: pooka Date: Wed Feb 16 19:26:59 UTC 2011
Modified Files: src/lib/librumpclient: rumpclient.c src/lib/librumphijack: hijack.c Log Message: * set default server connection retry to 0 (no reconnection attempts). while for some cases attempting retry after server restart works brilliantly (e.g. firefox), in other cases it's quite disasterous (sshd doesn't like its file descriptors going missing and does not attempt to reopen them, leading to a quite catastophic loop of EBADF once the server does come back) * rename RUMPHIJACK_RETRY to the slightly more sensible RUMPHIJACK_RETRYCONNECT To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/lib/librumpclient/rumpclient.c cvs rdiff -u -r1.43 -r1.44 src/lib/librumphijack/hijack.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/librumpclient/rumpclient.c diff -u src/lib/librumpclient/rumpclient.c:1.31 src/lib/librumpclient/rumpclient.c:1.32 --- src/lib/librumpclient/rumpclient.c:1.31 Wed Feb 16 17:56:46 2011 +++ src/lib/librumpclient/rumpclient.c Wed Feb 16 19:26:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpclient.c,v 1.31 2011/02/16 17:56:46 pooka Exp $ */ +/* $NetBSD: rumpclient.c,v 1.32 2011/02/16 19:26:58 pooka Exp $ */ /* * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. @@ -88,7 +88,11 @@ static int doconnect(bool); static int handshake_req(struct spclient *, int, void *, int, bool); -time_t retrytimo = RUMPCLIENT_RETRYCONN_ONCE; +/* + * Default: don't retry. Most clients can't handle it + * (consider e.g. fds suddenly going missing). + */ +static time_t retrytimo = 0; static int send_with_recon(struct spclient *spc, const void *data, size_t dlen) @@ -102,8 +106,10 @@ rv = dosend(spc, data, dlen); if (__predict_false(rv == ENOTCONN || rv == EBADF)) { /* no persistent connections */ - if (retrytimo == 0) + if (retrytimo == 0) { + rv = ENOTCONN; break; + } if (retrytimo == RUMPCLIENT_RETRYCONN_DIE) exit(1); Index: src/lib/librumphijack/hijack.c diff -u src/lib/librumphijack/hijack.c:1.43 src/lib/librumphijack/hijack.c:1.44 --- src/lib/librumphijack/hijack.c:1.43 Wed Feb 16 17:56:46 2011 +++ src/lib/librumphijack/hijack.c Wed Feb 16 19:26:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hijack.c,v 1.43 2011/02/16 17:56:46 pooka Exp $ */ +/* $NetBSD: hijack.c,v 1.44 2011/02/16 19:26:58 pooka Exp $ */ /*- * Copyright (c) 2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: hijack.c,v 1.43 2011/02/16 17:56:46 pooka Exp $"); +__RCSID("$NetBSD: hijack.c,v 1.44 2011/02/16 19:26:58 pooka Exp $"); #define __ssp_weak_name(fun) _hijack_ ## fun @@ -256,11 +256,7 @@ err(1, "rumpclient init"); /* set client persistence level */ - if (getenv_r("RUMPHIJACK_RETRY", buf, sizeof(buf)) == -1) { - if (errno == ERANGE) - err(1, "invalid RUMPHIJACK_RETRY"); - rumpclient_setconnretry(RUMPCLIENT_RETRYCONN_INFTIME); - } else { + if (getenv_r("RUMPHIJACK_RETRYCONNECT", buf, sizeof(buf)) != -1) { if (strcmp(buf, "die") == 0) rumpclient_setconnretry(RUMPCLIENT_RETRYCONN_DIE); else if (strcmp(buf, "inftime") == 0) @@ -269,11 +265,12 @@ rumpclient_setconnretry(RUMPCLIENT_RETRYCONN_ONCE); else { time_t timeout; + char *ep; - timeout = (time_t)strtoll(buf, NULL, 10); - if (timeout <= 0) - errx(1, "RUMPHIJACK_RETRY must be keyword " - "or a positive integer, got: %s", buf); + timeout = (time_t)strtoll(buf, &ep, 10); + if (timeout <= 0 || ep != buf + strlen(buf)) + errx(1, "RUMPHIJACK_RETRYCONNECT must be " + "keyword or integer, got: %s", buf); rumpclient_setconnretry(timeout); }