Summary of the changes:
- Closing a socket one-way, results in errors when still trying to get OOB data from it. I.e. the OS signals an error because it knows that OOB data cannot be sent anymore.
Is this a kernel bug? Shutting down the socket for writes should still allow reads to complete. If the shutdown was for reads, then it's a pike bug that it's even trying to read from it.
Well, no. What happens is that the sending side writes the data (into the kernel/network buffers), then closes the descriptor for writing. At the receiving end we try to read OOB data, which returns with an ECONNRESET immediately; as we then try the normal read, we still receive all the data which was previously written into the buffers, and the normal read then rightfully ends with an EOF.
So, nothing is lost, the kernel is behaving allright. Then again, it is a bit confusing that the OOB read returns with ECONNRESET instead of simply returning 0 (i.e. EOF) in this case. I'm not fully up to speed what POSIX says about OOB behaviour, so I can't tell you if this is something that should be fixed in the kernel or not. It might be worth the trouble to bring this (IMO non-intuitive behaviour) to the attention of the FreeBSD developers.