From owner-p4-projects@FreeBSD.ORG Wed Jan 30 21:51:52 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CFB7316A46B; Wed, 30 Jan 2008 21:51:51 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 954E516A468 for ; Wed, 30 Jan 2008 21:51:51 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 8A9EE13C461 for ; Wed, 30 Jan 2008 21:51:51 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0ULpp5C013258 for ; Wed, 30 Jan 2008 21:51:51 GMT (envelope-from csjp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0ULppv9013255 for perforce@freebsd.org; Wed, 30 Jan 2008 21:51:51 GMT (envelope-from csjp@freebsd.org) Date: Wed, 30 Jan 2008 21:51:51 GMT Message-Id: <200801302151.m0ULppv9013255@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to csjp@freebsd.org using -f From: "Christian S.J. Peron" To: Perforce Change Reviews Cc: Subject: PERFORCE change 134487 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jan 2008 21:51:52 -0000 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 #else /* WIN32 */ #include +#include #endif /* WIN32 */ #include @@ -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)