Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Jan 2008 21:51:51 GMT
From:      "Christian S.J. Peron" <csjp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 134487 for review
Message-ID:  <200801302151.m0ULppv9013255@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=134487

Change 134487 by csjp@csjp_xor on 2008/01/30 21:51:29

	Check to see if this pcap instance was using the zerocopy buffer
	mode.  If it was, delete the mappings.  Note that p->buffer
	gets initialized to one of the mmaped regions in this case, so
	do not try and free it directly.

Affected files ...

.. //depot/projects/zcopybpf/src/contrib/libpcap/pcap.c#3 edit

Differences ...

==== //depot/projects/zcopybpf/src/contrib/libpcap/pcap.c#3 (text+ko) ====

@@ -44,6 +44,7 @@
 #include <pcap-stdinc.h>
 #else /* WIN32 */
 #include <sys/types.h>
+#include <sys/mman.h>
 #endif /* WIN32 */
 
 #include <stdio.h>
@@ -738,6 +739,24 @@
 void
 pcap_close_common(pcap_t *p)
 {
+#ifdef BIOCSETBUFMODE
+	/*
+	 * Check to see if this pcap instance was using the zerocopy buffer
+	 * mode.  If it was, delete the mappings.  Note that p->buffer
+	 * gets initialized to one of the mmaped regions in this case, so
+	 * do not try and free it directly.
+	 *
+	 * If the regular buffer mode was selected, then it is safe to free
+	 * this memory.
+	 */
+	if (p->zerocopy) {
+		if (p->zbuf1 != MAP_FAILED && p->zbuf1 != NULL)
+			munmap(p->zbuf1, p->zbufsize);
+		if (p->zbuf2 != MAP_FAILED && p->zbuf2 != NULL)
+			munmap(p->zbuf2, p->zbufsize);
+		p->buffer = NULL;
+	} else
+#endif
 	if (p->buffer != NULL)
 		free(p->buffer);
 #if !defined(WIN32) && !defined(MSDOS)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801302151.m0ULppv9013255>