summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Graf <tgraf@redhat.com>2012-04-21 12:46:01 +0200
committerThomas Graf <tgraf@redhat.com>2012-04-21 12:46:01 +0200
commite0482794a8b70ae23361bfbe3701d4c2c96c66a6 (patch)
tree7f41b9af237b67fd19866fd3d02cadb89a069c74
parentadbc5687358ef62c5edb349332b3d031c01fcbb2 (diff)
downloadlibnl-e0482794a8b70ae23361bfbe3701d4c2c96c66a6.tar.gz
nl: Make nl_recvmsgs() return the number of netlink messages processed
-rw-r--r--lib/nl.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/nl.c b/lib/nl.c
index bcf89da..c41a3b9 100644
--- a/lib/nl.c
+++ b/lib/nl.c
@@ -559,7 +559,7 @@ do { \
static int recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
{
- int n, err = 0, multipart = 0, interrupted = 0;
+ int n, err = 0, multipart = 0, interrupted = 0, nrecv = 0;
unsigned char *buf = NULL;
struct nlmsghdr *hdr;
struct sockaddr_nl nla = {0};
@@ -594,6 +594,8 @@ continue_reading:
if (creds)
nlmsg_set_creds(msg, creds);
+ nrecv++;
+
/* Raw callback is the first, it gives the most control
* to the user and he can do his very own parsing. */
if (cb->cb_set[NL_CB_MSG_IN])
@@ -754,6 +756,9 @@ out:
if (interrupted)
err = -NLE_DUMP_INTR;
+ if (!err)
+ err = nrecv;
+
return err;
}
@@ -770,7 +775,7 @@ out:
* A non-blocking sockets causes the function to return immediately if
* no data is available.
*
- * @return 0 on success or a negative error code from nl_recv().
+ * @return Number of received messages or a negative error code from nl_recv().
*/
int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
{