Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/librumphijack make it possible to specify client connect...
details: https://anonhg.NetBSD.org/src/rev/43ee571f2dd8
branches: trunk
changeset: 761733:43ee571f2dd8
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Feb 06 15:48:20 2011 +0000
description:
make it possible to specify client connection retry model in
RUMPHIJACK_RETRY
diffstat:
lib/librumphijack/hijack.c | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diffs (66 lines):
diff -r 431f85e85bae -r 43ee571f2dd8 lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c Sun Feb 06 15:43:20 2011 +0000
+++ b/lib/librumphijack/hijack.c Sun Feb 06 15:48:20 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hijack.c,v 1.27 2011/02/06 13:05:19 pooka Exp $ */
+/* $NetBSD: hijack.c,v 1.28 2011/02/06 15:48:20 pooka Exp $ */
/*-
* Copyright (c) 2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: hijack.c,v 1.27 2011/02/06 13:05:19 pooka Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.28 2011/02/06 15:48:20 pooka Exp $");
#define __ssp_weak_name(fun) _hijack_ ## fun
@@ -52,6 +52,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <time.h>
#include <unistd.h>
@@ -185,6 +186,7 @@
static void __attribute__((constructor))
rcinit(void)
{
+ char buf[64];
extern void *(*rumpclient_dlsym)(void *, const char *);
unsigned i, j;
@@ -223,7 +225,30 @@
if (rumpclient_init() == -1)
err(1, "rumpclient init");
- rumpclient_setconnretry(RUMPCLIENT_RETRYCONN_INFTIME);
+
+ /* 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 (strcmp(buf, "die") == 0)
+ rumpclient_setconnretry(RUMPCLIENT_RETRYCONN_DIE);
+ else if (strcmp(buf, "inftime") == 0)
+ rumpclient_setconnretry(RUMPCLIENT_RETRYCONN_INFTIME);
+ else if (strcmp(buf, "once") == 0)
+ rumpclient_setconnretry(RUMPCLIENT_RETRYCONN_ONCE);
+ else {
+ time_t timeout;
+
+ timeout = (time_t)strtoll(buf, NULL, 10);
+ if (timeout <= 0)
+ errx(1, "RUMPHIJACK_RETRY must be keyword "
+ "or a positive integer, got: %s", buf);
+
+ rumpclient_setconnretry(timeout);
+ }
+ }
}
/* XXX: need runtime selection. low for now due to FD_SETSIZE */
Home |
Main Index |
Thread Index |
Old Index