Nethttpclient doesn't open several connections
Although number_of_parallel_connections has been increased this code still opens only one connection:
for n = 1 to 1000 do let msg = create() in client#add_with_callback msg (fun msg -> printf "Status: %d\n" msg#response_status_code; printf "Body:\n%s\n%!" msg#response_body#value; printf "Open connections: %d\n%!" client#number_of_open_connections ); done; client # run()
Suspicios code in nethttp_client.ml:
let empty_conns = List.exists (fun c -> c#length = 0) !connlist in if not empty_conns && List.length !connlist < !options.number_of_parallel_connections then <open_another_connection> else <push_request_to_existing_connection>
What if c#length is not updated immediately when the message is pushed to the queue? Because:
method length = match fp_opt with | None -> 0 | Some fp -> fp#length
So, when we don't have a real TCP connection yet, we always report 0.
Suggested fix: Change
method length = match fp_opt with | None -> Q.length queue | Some fp -> fp#length
Needs to be checked whether this is compatible with the other callers of
length, of course.