Skip to content

Commit 07a71ec

Browse files
committed
issue: 2439102 Fix issue with processing control msg in recvmsg()
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]>
1 parent d2db645 commit 07a71ec

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/vma/sock/sockinfo_tcp.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,9 +1957,13 @@ ssize_t sockinfo_tcp::rx(const rx_call_t call_type, iovec* p_iov, ssize_t sz_iov
19571957

19581958
/* poll rx queue till we have something */
19591959
lock_tcp_con();
1960-
if (__msg) {
1961-
handle_cmsg(__msg, in_flags);
1962-
if (__msg->msg_controllen == 0) {
1960+
1961+
/* error queue request should be handled first
1962+
* It allows to return immediately during failure with correct
1963+
* error notification without data processing
1964+
*/
1965+
if (__msg && __msg->msg_control && (in_flags & MSG_ERRQUEUE)) {
1966+
if (m_error_queue.empty()) {
19631967
errno = EAGAIN;
19641968
unlock_tcp_con();
19651969
return -1;
@@ -1982,6 +1986,11 @@ ssize_t sockinfo_tcp::rx(const rx_call_t call_type, iovec* p_iov, ssize_t sz_iov
19821986
total_rx = dequeue_packet(p_iov, sz_iov, (sockaddr_in *)__from, __fromlen, in_flags, &out_flags);
19831987
}
19841988

1989+
/* Handle all control message requests */
1990+
if (__msg && __msg->msg_control) {
1991+
handle_cmsg(__msg, in_flags);
1992+
}
1993+
19851994
/*
19861995
* RCVBUFF Accounting: Going 'out' of the internal buffer: if some bytes are not tcp_recved yet - do that.
19871996
* The packet might not be 'acked' (tcp_recved)

0 commit comments

Comments
 (0)