As far as I can tell, enabling IP_RECVERR causes the presence of a
queued error to cause recvmsg, etc to return an error (once). It's
worse, though: a new error can be queued asynchronously at any time,
this setting sk_err to a nonzero value. How do I sensibly distinguish
recvmsg failures to to genuine errors receiving messages from recvmsg
failures because there's a queued error?
The only way I can see to get reliable error handling is to literally
call recvmsg in a loop:
while (true /* or while POLLIN is set */) {
int ret = recvmsg(..., MSG_ERRQUEUE not set);
if (ret < 0 && /* what goes here? */) {
whoops! this might be a harmless asynchronous error!
take no action!
}
/* if POLLERR (or maybe unconditionally), recvmsg(..., MSG_ERRQUEUE);
}
The problem is that, if I'm screwing something up (thus causing EINVAL
or something similar), this will just spin forever.
Am I missing something here? Would it make sense to add
MSG_IGNORE_ERROR to suppress the sock_error check or IP_RECVERR=2 to
stop setting sk_err?
Thanks,
Andy
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html