Congratulations, you found a kernel bug. MSG_PEEK is not supposed to reset so->so_{r,}error. Try this (not even compile-tested). christos diff -u -u -r1.281 uipc_socket.c --- uipc_socket.c 16 Jul 2019 22:57:55 -0000 1.281 +++ uipc_socket.c 14 Sep 2019 13:52:57 -0000 @@ -928,7 +928,8 @@ } if (so->so_error) { error = so->so_error; - so->so_error = 0; + if ((flags & MSG_PEEK) == 0) + so->so_error = 0; goto release; } if ((so->so_state & SS_ISCONNECTED) == 0) { @@ -1227,13 +1228,10 @@ if (so->so_error || so->so_rerror) { if (m != NULL) goto dontblock; - if (so->so_error) { - error = so->so_error; - so->so_error = 0; - } else { - error = so->so_rerror; - so->so_rerror = 0; - } + int *e = so->so_error ? &so->so_error : &so->so_rerror; + error = *e; + if ((flags & MSG_PEEK) == 0) + *e = 0; goto release; } if (so->so_state & SS_CANTRCVMORE) {
|