From owner-freebsd-bugs@FreeBSD.ORG Tue Jan 18 19:00:44 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 57FE316A4CE for ; Tue, 18 Jan 2005 19:00:44 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2AADD43D54 for ; Tue, 18 Jan 2005 19:00:44 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id j0IJ0iRH047516 for ; Tue, 18 Jan 2005 19:00:44 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id j0IJ0hk6047515; Tue, 18 Jan 2005 19:00:43 GMT (envelope-from gnats) Resent-Date: Tue, 18 Jan 2005 19:00:43 GMT Resent-Message-Id: <200501181900.j0IJ0hk6047515@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Steven Harltand Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9656416A4CE; Tue, 18 Jan 2005 18:54:59 +0000 (GMT) Received: from dev1.multiplay.co.uk (dev1.multiplay.co.uk [212.42.16.81]) by mx1.FreeBSD.org (Postfix) with ESMTP id 073B943D45; Tue, 18 Jan 2005 18:54:59 +0000 (GMT) (envelope-from root@dev1.multiplay.co.uk) Received: from dev1.multiplay.co.uk (localhost.multiplay.co.uk [127.0.0.1]) j0IIsxf1023146; Tue, 18 Jan 2005 18:54:59 GMT (envelope-from root@dev1.multiplay.co.uk) Received: (from root@localhost) by dev1.multiplay.co.uk (8.12.10/8.12.10/Submit) id j0IIsxtr023145; Tue, 18 Jan 2005 18:54:59 GMT (envelope-from root) Message-Id: <200501181854.j0IIsxtr023145@dev1.multiplay.co.uk> Date: Tue, 18 Jan 2005 18:54:59 GMT From: Steven Harltand To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: "freebsd-emulation@FreeBSD.org" Subject: kern/76426: Linux ABI doesn't support MSG_NOSIGNAL X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Steven Harltand List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2005 19:00:44 -0000 >Number: 76426 >Category: kern >Synopsis: Linux ABI doesn't support MSG_NOSIGNAL >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Jan 18 19:00:43 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Steven Hartland >Release: FreeBSD 5.2.1-RELEASE-p13 i386 >Organization: Multiplay UK >Environment: System: FreeBSD dev1.multiplay.co.uk 5.2.1-RELEASE-p13 FreeBSD 5.2.1-RELEASE-p13 #0: Tue Jan 18 11:07:10 GMT 2005 root@dev1.multiplay.co.uk:/usr/src/sys/i386/compile/MPUK_SINGLE_200HZ i386 >Description: The linux ABI doesnt support MSG_NOSIGNAL it just gets lost in linux_send. The attached patch temporatly set SO_NOSIGPIPE on the socket fixing this issue. Im not 100% sure this is the best way of doing it but it works. >How-To-Repeat: Set the MSG_NOSIGNAL on a long running send and close the reciever. SIGPIPE should be ignored but its not currently, causing the sender to exit if not caught manually. >Fix: Apply the following patch: --- linux_socket.c.orig Tue Jan 18 10:41:32 2005 +++ linux_socket.c Tue Jan 18 11:02:37 2005 @@ -869,5 +869,48 @@ bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; - return (osend(td, &bsd_args)); + if ( linux_args.flags & LINUX_MSG_NOSIGNAL ) + { + /* requested to ignore pipe so set SO_NOSIGPIPE temporarily */ + int ret_send, ret_opt; + struct setsockopt_args /* { + int s; + int level; + int name; + caddr_t val; + int valsize; + } */ bsd_setsockopt_args; + caddr_t sg; + int *nosigpipe; + + sg = stackgap_init(); + nosigpipe = (int *)stackgap_alloc(&sg, sizeof(*nosigpipe)); + *nosigpipe = 1; + bsd_setsockopt_args.s = linux_args.s; + bsd_setsockopt_args.level = SOL_SOCKET; + bsd_setsockopt_args.name = SO_NOSIGPIPE; + bsd_setsockopt_args.val = (caddr_t)nosigpipe; + bsd_setsockopt_args.valsize = sizeof(*nosigpipe); + ret_opt = setsockopt(td, &bsd_setsockopt_args); + if ( -1 == ret_opt ) + { + return ret_opt; + } + + ret_send = (osend(td, &bsd_args)); + /* must clear the option */ + *nosigpipe = 1; + bsd_setsockopt_args.val = (caddr_t)nosigpipe; + ret_opt = setsockopt(td, &bsd_setsockopt_args); + if ( -1 == ret_send || -1 == ret_opt ) + { + return -1; + } + + return ret_send; + } + else + { + return (osend(td, &bsd_args)); + } } >Release-Note: >Audit-Trail: >Unformatted: