PERFORCE change 127151 for review

Fredrik Lindberg fli at FreeBSD.org
Wed Oct 3 14:32:40 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=127151

Change 127151 by fli at fli_nexus on 2007/10/03 21:32:25

	- Ignore empty packets.
	- Abort transmission if memory allocation fails.

Affected files ...

.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/stack_mdns.c#7 edit

Differences ...

==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/stack_mdns.c#7 (text+ko) ====

@@ -622,6 +622,7 @@
 	struct mdns_packet *pkg;
 	struct mdns_buf *buf;
 	int i, error;
+	size_t len;
 	struct iovec *iov;
 	struct msghdr msg;
 
@@ -629,6 +630,7 @@
 	msg.msg_namelen = salen;
 	msg.msg_control = NULL;
 	msg.msg_controllen = 0;
+	len = 0;
 
 	TAILQ_FOREACH(pkg, &pc->pc_head, p_list) {
 		iov = malloc(sizeof(struct iovec) *
@@ -638,7 +640,12 @@
 			iov[i].iov_base = MDNS_BUF(buf);
 			iov[i].iov_len = MDNS_BUFLEN(buf);
 			i++;
+			len += MDNS_BUFLEN(buf);
 		}
+		if (len == 0) {
+			free(iov);
+			continue;
+		}
 
 		msg.msg_iov = iov;
 		msg.msg_iovlen = i;
@@ -646,7 +653,7 @@
 		error = sendmsg(sock, &msg, 0);
 		free(iov);
 		if (error < 0)
-			return (-1);
+			continue;
 	}
 	return (0);
 }


More information about the p4-projects mailing list