reconnect_set_passive(s->reconnect, true, time_msec());
}
+ if (!stream_or_pstream_needs_probes(name)) {
+ reconnect_set_probe_interval(s->reconnect, 0);
+ }
+
return s;
}
static const struct stream_class stream_fd_class = {
"fd", /* name */
+ false, /* needs_probes */
NULL, /* open */
fd_close, /* close */
fd_connect, /* connect */
static struct pstream_class fd_pstream_class = {
"pstream",
+ false,
NULL,
pfd_close,
pfd_accept,
/* 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.
/* 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.
const struct stream_class ssl_stream_class = {
"ssl", /* name */
+ true, /* needs_probes */
ssl_open, /* open */
ssl_close, /* close */
ssl_connect, /* connect */
const struct pstream_class pssl_pstream_class = {
"pssl",
+ true,
pssl_open,
pssl_close,
pssl_accept,
const struct stream_class tcp_stream_class = {
"tcp", /* name */
+ true, /* needs_probes */
tcp_open, /* open */
NULL, /* close */
NULL, /* connect */
const struct pstream_class ptcp_pstream_class = {
"ptcp",
+ true,
ptcp_open,
NULL,
NULL,
const struct stream_class unix_stream_class = {
"unix", /* name */
+ false, /* needs_probes */
unix_open, /* open */
NULL, /* close */
NULL, /* connect */
const struct pstream_class punix_pstream_class = {
"punix",
+ false,
punix_open,
NULL,
NULL,
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.
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. */
}
struct ovsdb_jsonrpc_options *
-ovsdb_jsonrpc_default_options(void)
+ovsdb_jsonrpc_default_options(const char *target)
{
struct ovsdb_jsonrpc_options *options = xzalloc(sizeof *options);
- options->probe_interval = RECONNECT_DEFAULT_PROBE_INTERVAL;
options->max_backoff = RECONNECT_DEFAULT_MAX_BACKOFF;
+ options->probe_interval = (stream_or_pstream_needs_probes(target)
+ ? RECONNECT_DEFAULT_PROBE_INTERVAL
+ : 0);
return options;
}
int probe_interval; /* Max idle time before probing, in msec. */
int dscp; /* Dscp value for manager connections */
};
-struct ovsdb_jsonrpc_options *ovsdb_jsonrpc_default_options(void);
+struct ovsdb_jsonrpc_options *
+ovsdb_jsonrpc_default_options(const char *target);
void ovsdb_jsonrpc_server_set_remotes(struct ovsdb_jsonrpc_server *,
const struct shash *);
options = shash_find_data(remotes, target);
if (!options) {
- options = ovsdb_jsonrpc_default_options();
+ options = ovsdb_jsonrpc_default_options(target);
shash_add(remotes, target, options);
}
if ovs.stream.PassiveStream.is_valid_name(name):
reconnect.set_passive(True, ovs.timeval.msec())
+ if ovs.stream.stream_or_pstream_needs_probes(name):
+ reconnect.set_probe_interval(0)
+
return Session(reconnect, None)
@staticmethod
vlog = ovs.vlog.Vlog("stream")
+def stream_or_pstream_needs_probes(name):
+ """ 1 if the stream or pstream specified by 'name' needs periodic probes to
+ verify connectivty. For [p]streams which need probes, it can take a long
+ time to notice the connection was dropped. Returns 0 if probes aren't
+ needed, and -1 if 'name' is invalid"""
+
+ if PassiveStream.is_valid_name(name) or Stream.is_valid_name(name):
+ # Only unix and punix are supported currently.
+ return 0
+ else:
+ return -1
+
+
class Stream(object):
"""Bidirectional byte stream. Currently only Unix domain sockets
are implemented."""