Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib * set default server connection retry to 0 (no reconnect...



details:   https://anonhg.NetBSD.org/src/rev/cdc8ed646fa6
branches:  trunk
changeset: 762151:cdc8ed646fa6
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Feb 16 19:26:58 2011 +0000

description:
* 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

diffstat:

 lib/librumpclient/rumpclient.c |  12 +++++++++---
 lib/librumphijack/hijack.c     |  19 ++++++++-----------
 2 files changed, 17 insertions(+), 14 deletions(-)

diffs (82 lines):

diff -r e2b4eb0db10c -r cdc8ed646fa6 lib/librumpclient/rumpclient.c
--- a/lib/librumpclient/rumpclient.c    Wed Feb 16 19:08:57 2011 +0000
+++ b/lib/librumpclient/rumpclient.c    Wed Feb 16 19:26:58 2011 +0000
@@ -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);
 
diff -r e2b4eb0db10c -r cdc8ed646fa6 lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c        Wed Feb 16 19:08:57 2011 +0000
+++ b/lib/librumphijack/hijack.c        Wed Feb 16 19:26:58 2011 +0000
@@ -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);
                }



Home | Main Index | Thread Index | Old Index