dect
/
libnl
Archived
13
0
Fork 0

nl: Fix return value of nl_recvmsgs()

Apparently the change to have nl_recvmsgs() return the number of
parsed messages broke nl_wait_for_ack() among other applications.

This patch reverts to the old behaviour and provides a new function
nl_recvmsgs_report() which provides the additional information for
use by the cache manager and possibly other applications.

Reported-by: Scott Bonar <sbonar@cradlepoint.com>
Signed-off-by: Thomas Graf <tgraf@redhat.com>
This commit is contained in:
Thomas Graf 2012-05-08 22:48:00 +02:00
parent d726ecd2d7
commit 6f156a7b58
3 changed files with 31 additions and 6 deletions

View File

@ -71,6 +71,7 @@ extern int nl_recv(struct nl_sock *,
struct ucred **);
extern int nl_recvmsgs(struct nl_sock *, struct nl_cb *);
extern int nl_recvmsgs_report(struct nl_sock *, struct nl_cb *);
extern int nl_recvmsgs_default(struct nl_sock *);

View File

@ -359,7 +359,7 @@ int nl_cache_mngr_data_ready(struct nl_cache_mngr *mngr)
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, event_input, mngr);
while ((err = nl_recvmsgs(mngr->cm_sock, cb)) > 0) {
while ((err = nl_recvmsgs_report(mngr->cm_sock, cb)) > 0) {
NL_DBG(2, "Cache manager %p, recvmsgs read %d messages\n",
mngr, err);
nread += err;

View File

@ -762,6 +762,26 @@ out:
return err;
}
/**
* Receive a set of messages from a netlink socket and report parsed messages
* @arg sk Netlink socket.
* @arg cb set of callbacks to control behaviour.
*
* This function is identical to nl_recvmsgs() to the point that it will
* return the number of parsed messages instead of 0 on success.
*
* @see nl_recvmsgs()
*
* @return Number of received messages or a negative error code from nl_recv().
*/
int nl_recvmsgs_report(struct nl_sock *sk, struct nl_cb *cb)
{
if (cb->cb_recvmsgs_ow)
return cb->cb_recvmsgs_ow(sk, cb);
else
return recvmsgs(sk, cb);
}
/**
* Receive a set of messages from a netlink socket.
* @arg sk Netlink socket.
@ -775,14 +795,18 @@ out:
* A non-blocking sockets causes the function to return immediately if
* no data is available.
*
* @return Number of received messages or a negative error code from nl_recv().
* @see nl_recvmsgs_report()
*
* @return 0 on success or a negative error code from nl_recv().
*/
int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
{
if (cb->cb_recvmsgs_ow)
return cb->cb_recvmsgs_ow(sk, cb);
else
return recvmsgs(sk, cb);
int err;
if ((err = nl_recvmsgs_report(sk, cb)) > 0)
err = 0;
return err;
}
/**