summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2012-04-11 20:18:34 -0700
committerEthan Jackson <ethan@nicira.com>2012-04-12 00:43:22 -0700
commitf1936eb65178f796d26a8d265697af8c19dce8cd (patch)
tree05616ee0958f35adcb6822354a74905a89f659b1 /lib
parentbceb55c8ba91af812bc61e1ebc54f367ad034157 (diff)
downloadopenvswitch-f1936eb65178f796d26a8d265697af8c19dce8cd.tar.gz
stream: By default disable probing on unix sockets.
There isn't a lot of value in sending inactivity probes on unix sockets. This patch changes the default to disable them. Signed-off-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/jsonrpc.c4
-rw-r--r--lib/stream-fd.c2
-rw-r--r--lib/stream-provider.h10
-rw-r--r--lib/stream-ssl.c2
-rw-r--r--lib/stream-tcp.c2
-rw-r--r--lib/stream-unix.c2
-rw-r--r--lib/stream.c19
-rw-r--r--lib/stream.h1
8 files changed, 42 insertions, 0 deletions
diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index fa3362d17..e95db8afc 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -764,6 +764,10 @@ jsonrpc_session_open(const char *name)
reconnect_set_passive(s->reconnect, true, time_msec());
}
+ if (!stream_or_pstream_needs_probes(name)) {
+ reconnect_set_probe_interval(s->reconnect, 0);
+ }
+
return s;
}
diff --git a/lib/stream-fd.c b/lib/stream-fd.c
index 38dba7c71..4113e3fc1 100644
--- a/lib/stream-fd.c
+++ b/lib/stream-fd.c
@@ -150,6 +150,7 @@ fd_wait(struct stream *stream, enum stream_wait_type wait)
static const struct stream_class stream_fd_class = {
"fd", /* name */
+ false, /* needs_probes */
NULL, /* open */
fd_close, /* close */
fd_connect, /* connect */
@@ -255,6 +256,7 @@ pfd_wait(struct pstream *pstream)
static struct pstream_class fd_pstream_class = {
"pstream",
+ false,
NULL,
pfd_close,
pfd_accept,
diff --git a/lib/stream-provider.h b/lib/stream-provider.h
index 77d0a1060..3decb5a8a 100644
--- a/lib/stream-provider.h
+++ b/lib/stream-provider.h
@@ -54,6 +54,11 @@ struct stream_class {
/* Prefix for connection names, e.g. "tcp", "ssl", "unix". */
const char *name;
+ /* True if this stream needs periodic probes to verify connectivty. For
+ * streams which need probes, it can take a long time to notice the
+ * connection was dropped. */
+ bool needs_probes;
+
/* Attempts to connect to a peer. 'name' is the full connection name
* provided by the user, e.g. "tcp:1.2.3.4". This name is useful for error
* messages but must not be modified.
@@ -151,6 +156,11 @@ struct pstream_class {
/* Prefix for connection names, e.g. "ptcp", "pssl", "punix". */
const char *name;
+ /* True if this pstream needs periodic probes to verify connectivty. For
+ * pstreams which need probes, it can take a long time to notice the
+ * connection was dropped. */
+ bool needs_probes;
+
/* Attempts to start listening for stream connections. 'name' is the full
* connection name provided by the user, e.g. "ptcp:1234". This name is
* useful for error messages but must not be modified.
diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c
index 5463388ea..ad572d352 100644
--- a/lib/stream-ssl.c
+++ b/lib/stream-ssl.c
@@ -755,6 +755,7 @@ ssl_wait(struct stream *stream, enum stream_wait_type wait)
const struct stream_class ssl_stream_class = {
"ssl", /* name */
+ true, /* needs_probes */
ssl_open, /* open */
ssl_close, /* close */
ssl_connect, /* connect */
@@ -861,6 +862,7 @@ pssl_wait(struct pstream *pstream)
const struct pstream_class pssl_pstream_class = {
"pssl",
+ true,
pssl_open,
pssl_close,
pssl_accept,
diff --git a/lib/stream-tcp.c b/lib/stream-tcp.c
index c7a2ee2e8..9762f88ed 100644
--- a/lib/stream-tcp.c
+++ b/lib/stream-tcp.c
@@ -86,6 +86,7 @@ tcp_open(const char *name, char *suffix, struct stream **streamp, uint8_t dscp)
const struct stream_class tcp_stream_class = {
"tcp", /* name */
+ true, /* needs_probes */
tcp_open, /* open */
NULL, /* close */
NULL, /* connect */
@@ -137,6 +138,7 @@ ptcp_accept(int fd, const struct sockaddr *sa, size_t sa_len,
const struct pstream_class ptcp_pstream_class = {
"ptcp",
+ true,
ptcp_open,
NULL,
NULL,
diff --git a/lib/stream-unix.c b/lib/stream-unix.c
index a9d76f257..40ef01248 100644
--- a/lib/stream-unix.c
+++ b/lib/stream-unix.c
@@ -57,6 +57,7 @@ unix_open(const char *name, char *suffix, struct stream **streamp,
const struct stream_class unix_stream_class = {
"unix", /* name */
+ false, /* needs_probes */
unix_open, /* open */
NULL, /* close */
NULL, /* connect */
@@ -113,6 +114,7 @@ punix_accept(int fd, const struct sockaddr *sa, size_t sa_len,
const struct pstream_class punix_pstream_class = {
"punix",
+ false,
punix_open,
NULL,
NULL,
diff --git a/lib/stream.c b/lib/stream.c
index 2f418c42a..eabace8a4 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -489,6 +489,25 @@ pstream_verify_name(const char *name)
return pstream_lookup_class(name, &class);
}
+/* Returns 1 if the stream or pstream specified by 'name' needs periodic probes
+ * to verify connectivity. For [p]streams which need probes, it can take a
+ * long time to notice the connection has been dropped. Returns 0 if the
+ * stream or pstream does not need probes, and -1 if 'name' is not valid. */
+int
+stream_or_pstream_needs_probes(const char *name)
+{
+ const struct pstream_class *pclass;
+ const struct stream_class *class;
+
+ if (!stream_lookup_class(name, &class)) {
+ return class->needs_probes;
+ } else if (!pstream_lookup_class(name, &pclass)) {
+ return pclass->needs_probes;
+ } else {
+ return -1;
+ }
+}
+
/* Attempts to start listening for remote stream connections. 'name' is a
* connection name in the form "TYPE:ARGS", where TYPE is an passive stream
* class's name and ARGS are stream class-specific.
diff --git a/lib/stream.h b/lib/stream.h
index c1f3adb6b..bd3901747 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -82,6 +82,7 @@ bool stream_parse_target_with_default_ports(const char *target,
uint16_t default_tcp_port,
uint16_t default_ssl_port,
struct sockaddr_in *sin);
+int stream_or_pstream_needs_probes(const char *name);
/* Error reporting. */