This patch addresses the close hang reported in bugzilla PR 212716 (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=212716)
Socket state may have changed after dropping the receive
buffer lock in order to call pr_rcvd(). If the buffer is
empty, re-check the state after reaquiring the lock and
skip calling sbwait() if the socket is in error or the
peer has closed.
Much thanks to markj for the regression test (which will be applied as a separate commit prior to the actual fix).