PERFORCE change 141921 for review

Christian S.J. Peron csjp at FreeBSD.org
Tue May 20 15:36:14 UTC 2008


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

Change 141921 by csjp at ibm01 on 2008/05/20 15:36:00

	Use setsockopt(2) so we can re-use the address previously bound to.

Affected files ...

.. //depot/projects/trustedbsd/netauditd/reader.c#6 edit

Differences ...

==== //depot/projects/trustedbsd/netauditd/reader.c#6 (text+ko) ====

@@ -223,12 +223,19 @@
 int
 reader_init_net(struct au_cmpnt *ac)
 {
-	int fd;
+	int fd, opt;
+	socklen_t olen;
 
 	fd = socket(ac->ac_ainfo->ai_family, ac->ac_ainfo->ai_socktype,
 	    ac->ac_ainfo->ai_protocol);
 	if (fd == -1)
 		return (-1);
+	opt = 1;
+	olen = sizeof(opt);
+	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, olen) < 0) {
+		(void) close(fd);
+		return (-1);
+	}
 	if (bind(fd, ac->ac_ainfo->ai_addr, ac->ac_ainfo->ai_addrlen) == -1) {
 		(void) close(fd);
 		return (-1);


More information about the p4-projects mailing list