diff mbox series

[ovs-dev,v2,2/4] Run JSON RPC if there is backlog

Message ID 20200214175429.26111-2-anton.ivanov@cambridgegreys.com
State Changes Requested
Headers show
Series [ovs-dev,v2,1/4] Replace direct use of POLLXXX macros with OVS_POLLXXX | expand

Commit Message

Anton Ivanov Feb. 14, 2020, 5:54 p.m. UTC
From: Anton Ivanov <anton.ivanov@cambridgegreys.com>

Run JSON RPC every time there is a backlog and not only if
backlog was created on this iteration.

Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
---
 lib/jsonrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff Feb. 14, 2020, 9:13 p.m. UTC | #1
On Fri, Feb 14, 2020 at 05:54:27PM +0000, anton.ivanov@cambridgegreys.com wrote:
> From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> 
> Run JSON RPC every time there is a backlog and not only if
> backlog was created on this iteration.

The rationale for the current behavior is that the condition will be
true (and we will send the message) if the underlying socket's buffer
hasn't filled up.  However, if it did fill up, there is not much benefit
in trying to send another message; it will probably just waste a system
call.

The >= condition will always be true (unless there's an overflow), so
there's no point in testing it at all.
Anton Ivanov Feb. 14, 2020, 9:48 p.m. UTC | #2
On 14/02/2020 21:13, Ben Pfaff wrote:
> On Fri, Feb 14, 2020 at 05:54:27PM +0000, anton.ivanov@cambridgegreys.com wrote:
>> From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
>>
>> Run JSON RPC every time there is a backlog and not only if
>> backlog was created on this iteration.
> The rationale for the current behavior is that the condition will be
> true (and we will send the message) if the underlying socket's buffer
> hasn't filled up.  However, if it did fill up, there is not much benefit
> in trying to send another message; it will probably just waste a system
> call.

That is taken care of in the next patch in the series.

>
> The >= condition will always be true (unless there's an overflow), so
> there's no point in testing it at all.
OK. That makes sense provided send is synchronous (as it is today). We 
can skip it for now and revisit when offloading SSL to worker threads.
diff mbox series

Patch

diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index ed748dbde..fc354e517 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -266,7 +266,7 @@  jsonrpc_send(struct jsonrpc *rpc, struct jsonrpc_msg *msg)
                      rpc->output_count, rpc->backlog);
     }
 
-    if (rpc->backlog == length) {
+    if (rpc->backlog >= length) {
         jsonrpc_run(rpc);
     }
     return rpc->status;