Skip to content

Commit a035eaa

Browse files
committed
netlink-socket: extend comments a bit
Follow-up for 90755da.
1 parent e8881f0 commit a035eaa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/libsystemd/sd-netlink/netlink-socket.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ static int socket_recv_message(int fd, void *buf, size_t buf_size, uint32_t *ret
161161
assert(fd >= 0);
162162
assert(peek || (buf && buf_size > 0));
163163

164+
/* Note: this might return successfully, but with a zero size under some transient conditions, such
165+
* as the reception of a non-kernel message. In such a case the passed buffer might or might not be
166+
* modified. Caller must treat a zero return as "no message, but also not an error". */
167+
164168
n = recvmsg_safe(fd, &msg, peek ? (MSG_PEEK|MSG_TRUNC) : 0);
165169
if (ERRNO_IS_NEG_TRANSIENT(n))
166170
goto transient;
@@ -179,8 +183,9 @@ static int socket_recv_message(int fd, void *buf, size_t buf_size, uint32_t *ret
179183

180184
if (peek) {
181185
/* Drop the message. Note that we ignore ECHRNG/EXFULL errors here, which
182-
* recvmsg_safe() returns in case the payload or cdata is truncated. Here it's quite
183-
* likely it is truncated, because we pass a zero-sized buffer. */
186+
* recvmsg_safe() returns in case the payload or cdata is truncated. Given we just
187+
* want to drop the message we also don't care if its payload or cdata was
188+
* truncated. */
184189
n = recvmsg_safe(fd, &msg, 0);
185190
if (n < 0 && !IN_SET(n, -ECHRNG, -EXFULL))
186191
return (int) n;

0 commit comments

Comments
 (0)