api: comment, simplify and fix api socket read 51/24851/2
authorVratko Polak <[email protected]>
Mon, 7 Oct 2019 12:52:53 +0000 (14:52 +0200)
committerDave Barach <[email protected]>
Tue, 18 Feb 2020 13:28:25 +0000 (13:28 +0000)
commit72ab26ca8f1f4d28c41b39f994ac82f60552f41a
tree806a0c23fa300c37d025b8dfd587dd5edcb1b8d7
parent05c2f5b73e67994da1d4f5b61731608ee08c379d
api: comment, simplify and fix api socket read

The function vl_socket_read_ready did contain some comments already,
but as they stated, the logic has to be tricky to cover multiple cases.

Comment:
+ Add function-level comment
+ Add comments to describe some of local variables
+ Add many comments to describe internal state at particular lines.

Simplify:
+ Remov mbp_set as it is never needed.
+ Replace msg_len with msgbuf_len to save "+ sizeof (msgbuf_t)".

Improve:
+ Early exit on EAGAIN.

Fix:
+ "n" now only tracks input_buffer.
  Previously, it was entering the detection of additional messages
  even for unprocessed_input.
+ Set up msg_buffer (including appending to unprocessed_input)
  outside full-message-detection loop now,
  so it cannot be executed multiple times as before.

Type: fix
Ticket: VPP-1785

Change-Id: I256e34b435be06844458744a13ea37a0e86a96f9
Signed-off-by: Vratko Polak <[email protected]>
(cherry picked from commit 6a6af6ea1a77b5818e717047b5d01251ef6d024a)
src/vlibmemory/socket_api.c