No need to restart DB / OVS on changing dscp value.
[sliver-openvswitch.git] / lib / jsonrpc.c
index fc8a75b..ce5d2b4 100644 (file)
@@ -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
@@ -1054,5 +1058,8 @@ void
 jsonrpc_session_set_dscp(struct jsonrpc_session *s,
                          uint8_t dscp)
 {
-    s->dscp = dscp;
+    if (s->dscp != dscp) {
+        jsonrpc_session_force_reconnect(s);
+        s->dscp = dscp;
+    }
 }