From owner-freebsd-net@FreeBSD.ORG Sun Jun 29 16:36:05 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2640437B401 for ; Sun, 29 Jun 2003 16:36:05 -0700 (PDT) Received: from jchurch.neville-neil.com (jchurch.neville-neil.com [209.157.133.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9472B44027 for ; Sun, 29 Jun 2003 16:36:04 -0700 (PDT) (envelope-from gnn@neville-neil.com) Received: from jchurch.neville-neil.com.neville-neil.com (localhost [127.0.0.1])h5TNa3jb074274 for ; Sun, 29 Jun 2003 16:36:03 -0700 (PDT) (envelope-from gnn@neville-neil.com) Date: Sun, 29 Jun 2003 16:36:03 -0700 Message-ID: <87y8zkwj6k.wl@jchurch.neville-neil.com.neville-neil.com> From: "George V. Neville-Neil" To: freebsd-net@freebsd.org User-Agent: Wanderlust/2.10.0 (Venus) SEMI/1.14.4 (Hosorogi) FLIM/1.14.4 (=?ISO-8859-4?Q?Kashiharajing=FE-mae?=) APEL/10.4 Emacs/21.2 (i386--freebsd) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: text/plain; charset=US-ASCII Subject: Another question on locking... X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jun 2003 23:36:05 -0000 Hi, Looking at the code in uipc_socket.c and udp_usrreq.c I am a bit confused as to how the locking mechanism works between the sockets and the protocols. The socket calls all occur under Giant, which the protocols do not deal with, and the protocols all lock on the inp mutex, which the socket calls do not deal with. Furthermore the sblock/sbunlock calls are only use by the socket layer. I'm reading udp_input() as it's simpler to follow. Have I missed something? What prevents a protocol from writing to a socket buffer at the wrong time or the socket code from tweaking it at the wrong time? Is this handled simply because of the priority of the threads doing the work? Thanks, George