Skip to content

Commit

Permalink
issue: 2439102 Fix issue with processing control msg in recvmsg()
Browse files Browse the repository at this point in the history
Control message should be handled just in case an user
passes a buffer for it.
Error queue request must be processed first before data.

Signed-off-by: Igor Ivanov <[email protected]>
  • Loading branch information
igor-ivanov committed Feb 20, 2021
1 parent d2db645 commit 07a71ec
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/vma/sock/sockinfo_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1957,9 +1957,13 @@ ssize_t sockinfo_tcp::rx(const rx_call_t call_type, iovec* p_iov, ssize_t sz_iov

/* poll rx queue till we have something */
lock_tcp_con();
if (__msg) {
handle_cmsg(__msg, in_flags);
if (__msg->msg_controllen == 0) {

/* error queue request should be handled first
* It allows to return immediately during failure with correct
* error notification without data processing
*/
if (__msg && __msg->msg_control && (in_flags & MSG_ERRQUEUE)) {
if (m_error_queue.empty()) {
errno = EAGAIN;
unlock_tcp_con();
return -1;
Expand All @@ -1982,6 +1986,11 @@ ssize_t sockinfo_tcp::rx(const rx_call_t call_type, iovec* p_iov, ssize_t sz_iov
total_rx = dequeue_packet(p_iov, sz_iov, (sockaddr_in *)__from, __fromlen, in_flags, &out_flags);
}

/* Handle all control message requests */
if (__msg && __msg->msg_control) {
handle_cmsg(__msg, in_flags);
}

/*
* RCVBUFF Accounting: Going 'out' of the internal buffer: if some bytes are not tcp_recved yet - do that.
* The packet might not be 'acked' (tcp_recved)
Expand Down

0 comments on commit 07a71ec

Please sign in to comment.