git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dpif-netdev: Use RCU to protect data.
[sliver-openvswitch.git]
/
lib
/
jsonrpc.c
diff --git
a/lib/jsonrpc.c
b/lib/jsonrpc.c
index
56b4cce
..
643a3c5
100644
(file)
--- a/
lib/jsonrpc.c
+++ b/
lib/jsonrpc.c
@@
-26,6
+26,7
@@
#include "json.h"
#include "list.h"
#include "ofpbuf.h"
#include "json.h"
#include "list.h"
#include "ofpbuf.h"
+#include "ovs-thread.h"
#include "poll-loop.h"
#include "reconnect.h"
#include "stream.h"
#include "poll-loop.h"
#include "reconnect.h"
#include "stream.h"
@@
-41,6
+42,7
@@
struct jsonrpc {
/* Input. */
struct byteq input;
/* Input. */
struct byteq input;
+ uint8_t input_buffer[512];
struct json_parser *parser;
struct jsonrpc_msg *received;
struct json_parser *parser;
struct jsonrpc_msg *received;
@@
-57,22
+59,21
@@
static void jsonrpc_cleanup(struct jsonrpc *);
static void jsonrpc_error(struct jsonrpc *, int error);
/* This is just the same as stream_open() except that it uses the default
static void jsonrpc_error(struct jsonrpc *, int error);
/* This is just the same as stream_open() except that it uses the default
- * JSONRPC port
s
if none is specified. */
+ * JSONRPC port if none is specified. */
int
jsonrpc_stream_open(const char *name, struct stream **streamp, uint8_t dscp)
{
int
jsonrpc_stream_open(const char *name, struct stream **streamp, uint8_t dscp)
{
- return stream_open_with_default_ports(name, JSONRPC_TCP_PORT,
- JSONRPC_SSL_PORT, streamp,
- dscp);
+ return stream_open_with_default_port(name, OVSDB_OLD_PORT,
+ streamp, dscp);
}
/* This is just the same as pstream_open() except that it uses the default
}
/* This is just the same as pstream_open() except that it uses the default
- * JSONRPC port
s
if none is specified. */
+ * JSONRPC port if none is specified. */
int
jsonrpc_pstream_open(const char *name, struct pstream **pstreamp, uint8_t dscp)
{
int
jsonrpc_pstream_open(const char *name, struct pstream **pstreamp, uint8_t dscp)
{
- return pstream_open_with_default_port
s(name, JSONRPC_TCP
_PORT,
-
JSONRPC_SSL_PORT,
pstreamp, dscp);
+ return pstream_open_with_default_port
(name, OVSDB_OLD
_PORT,
+ pstreamp, dscp);
}
/* Returns a new JSON-RPC stream that uses 'stream' for input and output. The
}
/* Returns a new JSON-RPC stream that uses 'stream' for input and output. The
@@
-87,7
+88,7
@@
jsonrpc_open(struct stream *stream)
rpc = xzalloc(sizeof *rpc);
rpc->name = xstrdup(stream_get_name(stream));
rpc->stream = stream;
rpc = xzalloc(sizeof *rpc);
rpc->name = xstrdup(stream_get_name(stream));
rpc->stream = stream;
- byteq_init(&rpc->input);
+ byteq_init(&rpc->input
, rpc->input_buffer, sizeof rpc->input_buffer
);
list_init(&rpc->output);
return rpc;
list_init(&rpc->output);
return rpc;
@@
-330,7
+331,7
@@
jsonrpc_recv(struct jsonrpc *rpc, struct jsonrpc_msg **msgp)
jsonrpc_received(rpc);
if (rpc->status) {
const struct byteq *q = &rpc->input;
jsonrpc_received(rpc);
if (rpc->status) {
const struct byteq *q = &rpc->input;
- if (q->head <=
BYTEQ_SIZE
) {
+ if (q->head <=
q->size
) {
stream_report_content(q->buffer, q->head,
STREAM_JSONRPC,
THIS_MODULE, rpc->name);
stream_report_content(q->buffer, q->head,
STREAM_JSONRPC,
THIS_MODULE, rpc->name);
@@
-350,7
+351,7
@@
void
jsonrpc_recv_wait(struct jsonrpc *rpc)
{
if (rpc->status || rpc->received || !byteq_is_empty(&rpc->input)) {
jsonrpc_recv_wait(struct jsonrpc *rpc)
{
if (rpc->status || rpc->received || !byteq_is_empty(&rpc->input)) {
-
(poll_immediate_wake)
(rpc->name);
+
poll_immediate_wake_at
(rpc->name);
} else {
stream_recv_wait(rpc->stream);
}
} else {
stream_recv_wait(rpc->stream);
}
@@
-513,8
+514,11
@@
jsonrpc_create(enum jsonrpc_msg_type type, const char *method,
static struct json *
jsonrpc_create_id(void)
{
static struct json *
jsonrpc_create_id(void)
{
- static unsigned int id;
- return json_integer_create(id++);
+ static atomic_uint next_id = ATOMIC_VAR_INIT(0);
+ unsigned int id;
+
+ atomic_add(&next_id, 1, &id);
+ return json_integer_create(id);
}
struct jsonrpc_msg *
}
struct jsonrpc_msg *
@@
-1086,6
+1090,14
@@
jsonrpc_session_get_reconnect_stats(const struct jsonrpc_session *s,
reconnect_get_stats(s->reconnect, time_msec(), stats);
}
reconnect_get_stats(s->reconnect, time_msec(), stats);
}
+void
+jsonrpc_session_enable_reconnect(struct jsonrpc_session *s)
+{
+ reconnect_set_max_tries(s->reconnect, UINT_MAX);
+ reconnect_set_backoff(s->reconnect, RECONNECT_DEFAULT_MIN_BACKOFF,
+ RECONNECT_DEFAULT_MAX_BACKOFF);
+}
+
void
jsonrpc_session_force_reconnect(struct jsonrpc_session *s)
{
void
jsonrpc_session_force_reconnect(struct jsonrpc_session *s)
{