X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=lib%2Fjsonrpc.c;h=57613697779a6a35d648f631ebca110e031cd857;hb=6c4ea27c48b30eaec8e37e642d5072f53c5b2670;hp=fc8a75b08af1fbfe6694e36e2d4ecb514c515763;hpb=317f6420764f9024deead76fc98477327a8a180e;p=openvswitch diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index fc8a75b0..57613697 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks. + * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -277,13 +277,19 @@ jsonrpc_send(struct jsonrpc *rpc, struct jsonrpc_msg *msg) int jsonrpc_recv(struct jsonrpc *rpc, struct jsonrpc_msg **msgp) { + int i; + *msgp = NULL; if (rpc->status) { return rpc->status; } - while (!rpc->received) { - if (byteq_is_empty(&rpc->input)) { + for (i = 0; i < 50; i++) { + if (rpc->received) { + *msgp = rpc->received; + rpc->received = NULL; + return 0; + } else if (byteq_is_empty(&rpc->input)) { size_t chunk; int retval; @@ -328,9 +334,7 @@ jsonrpc_recv(struct jsonrpc *rpc, struct jsonrpc_msg **msgp) } } - *msgp = rpc->received; - rpc->received = NULL; - return 0; + return EAGAIN; } /* Causes the poll loop to wake up when jsonrpc_recv() may return a value other @@ -789,6 +793,7 @@ jsonrpc_session_open_unreliably(struct jsonrpc *jsonrpc) reconnect_set_name(s->reconnect, jsonrpc_get_name(jsonrpc)); reconnect_set_max_tries(s->reconnect, 0); reconnect_connected(s->reconnect, time_msec()); + s->dscp = 0; s->rpc = jsonrpc; s->stream = NULL; s->pstream = NULL; @@ -1054,5 +1059,8 @@ void jsonrpc_session_set_dscp(struct jsonrpc_session *s, uint8_t dscp) { - s->dscp = dscp; + if (s->dscp != dscp) { + s->dscp = dscp; + jsonrpc_session_force_reconnect(s); + } }