jsonrpc: Notify excessive sending backlog.
authorAlex Wang <alexw@nicira.com>
Thu, 18 Sep 2014 17:49:47 +0000 (10:49 -0700)
committerAlex Wang <alexw@nicira.com>
Tue, 23 Sep 2014 22:57:53 +0000 (15:57 -0700)
This commit adds a log message to notify the excessive backlog
for jsonrpc.  Expectedly, this message should never be printed.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/jsonrpc.c

index 842d117..cdec45a 100644 (file)
@@ -47,6 +47,7 @@ struct jsonrpc {
 
     /* Output. */
     struct list output;         /* Contains "struct ofpbuf"s. */
+    size_t output_count;        /* Number of elements in "output". */
     size_t backlog;
 };
 
@@ -124,6 +125,7 @@ jsonrpc_run(struct jsonrpc *rpc)
             ofpbuf_pull(buf, retval);
             if (!ofpbuf_size(buf)) {
                 list_remove(&buf->list_node);
+                rpc->output_count--;
                 ofpbuf_delete(buf);
             }
         } else {
@@ -257,8 +259,15 @@ jsonrpc_send(struct jsonrpc *rpc, struct jsonrpc_msg *msg)
     ofpbuf_use(buf, s, length);
     ofpbuf_set_size(buf, length);
     list_push_back(&rpc->output, &buf->list_node);
+    rpc->output_count++;
     rpc->backlog += length;
 
+    if (rpc->output_count >= 50) {
+        VLOG_INFO_RL(&rl, "excessive sending backlog, jsonrpc: %s, num of"
+                     " msgs: %"PRIuSIZE", backlog: %"PRIuSIZE".", rpc->name,
+                     rpc->output_count, rpc->backlog);
+    }
+
     if (rpc->backlog == length) {
         jsonrpc_run(rpc);
     }
@@ -496,6 +505,7 @@ jsonrpc_cleanup(struct jsonrpc *rpc)
 
     ofpbuf_list_delete(&rpc->output);
     rpc->backlog = 0;
+    rpc->output_count = 0;
 }
 \f
 static struct jsonrpc_msg *