From owner-cvs-all@FreeBSD.ORG Tue Jul 3 19:52:30 2007 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7E4A416A41F; Tue, 3 Jul 2007 19:52:30 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from turion.vk2pj.dyndns.org (c220-239-20-82.belrs4.nsw.optusnet.com.au [220.239.20.82]) by mx1.freebsd.org (Postfix) with ESMTP id 0309A13C487; Tue, 3 Jul 2007 19:52:29 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from turion.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by turion.vk2pj.dyndns.org (8.14.1/8.14.1) with ESMTP id l63JqSIY032255; Wed, 4 Jul 2007 05:52:28 +1000 (EST) (envelope-from peter@turion.vk2pj.dyndns.org) Received: (from peter@localhost) by turion.vk2pj.dyndns.org (8.14.1/8.14.1/Submit) id l63JqSi3032254; Wed, 4 Jul 2007 05:52:28 +1000 (EST) (envelope-from peter) Date: Wed, 4 Jul 2007 05:52:28 +1000 From: Peter Jeremy To: Robert Watson Message-ID: <20070703195228.GP15680@turion.vk2pj.dyndns.org> References: <200707031014.l63AEE9Y026819@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pE2VAHO2njSJCslu" Content-Disposition: inline In-Reply-To: <200707031014.l63AEE9Y026819@repoman.freebsd.org> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.15 (2007-04-06) Cc: cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/sys/sys socketvar.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jul 2007 19:52:30 -0000 --pE2VAHO2njSJCslu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2007-Jul-03 10:14:13 +0000, Robert Watson wrote: > Fix a bug in sblock() that has existed since revision 1.1 from BSD: > correctly return an error if M_NOWAIT is passed to sblock() and the > operation might block. This remarkably subtle macro bug appears to > be responsible for quite a few undiagnosed socket buffer corruption > and mbuf-related kernel panics. This bug would appear to be a classic example of the dangers of trying to force force multiple C statements into a single statement. IMHO, it (and many of the other macros in socketvar.h) should be inline functions, rather than macros. IMHO, the following is far more legible: static __inline int sblock(struct sockbuf *sb, int wf) { if (sb->sb_flags & SB_LOCK) return ((wf =3D=3D M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK); else { sb->sb_flags |=3D SB_LOCK; return (0); } } --=20 Peter Jeremy --pE2VAHO2njSJCslu Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFGiqj8/opHv/APuIcRArpaAKC2NEu4WSZCp1SfpMQMZtZkeOyB6wCeNpKM rLx8sl952WKNhYYL4aSercU= =UNvf -----END PGP SIGNATURE----- --pE2VAHO2njSJCslu--