X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fjsonrpc.c;h=643a3c5d0f827a6f0fee31dab5a7b8f4720526c4;hb=61e7deb14330d107464c2ea70ed2a9f2f1d27af6;hp=6c482c2d136a7ff1661baaef56cf0caae3f1117e;hpb=d7eea710a02193d6384174fa3f3e7d10d5248344;p=sliver-openvswitch.git diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index 6c482c2d1..643a3c5d0 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -59,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 - * JSONRPC ports if none is specified. */ + * JSONRPC port if none is specified. */ 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 - * JSONRPC ports if none is specified. */ + * JSONRPC port if none is specified. */ int jsonrpc_pstream_open(const char *name, struct pstream **pstreamp, uint8_t dscp) { - return pstream_open_with_default_ports(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 @@ -352,7 +351,7 @@ void 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); } @@ -515,14 +514,10 @@ jsonrpc_create(enum jsonrpc_msg_type type, const char *method, static struct json * jsonrpc_create_id(void) { - static pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER; - static unsigned int next_id; + static atomic_uint next_id = ATOMIC_VAR_INIT(0); unsigned int id; - xpthread_mutex_lock(&mutex); - id = next_id++; - xpthread_mutex_unlock(&mutex); - + atomic_add(&next_id, 1, &id); return json_integer_create(id); } @@ -1095,6 +1090,14 @@ jsonrpc_session_get_reconnect_stats(const struct jsonrpc_session *s, 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) {