From MAILER-DAEMON Sun Jan 08 09:14:41 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RjtWD-000892-PW for mharc-gpsd-dev@gnu.org; Sun, 08 Jan 2012 09:14:41 -0500 Received: from eggs.gnu.org ([140.186.70.92]:52285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjZUm-0008JD-U6 for gpsd-dev@nongnu.org; Sat, 07 Jan 2012 11:51:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RjZUl-0007bd-WF for gpsd-dev@nongnu.org; Sat, 07 Jan 2012 11:51:52 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:53186) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjZUl-0007bI-RI for gpsd-dev@nongnu.org; Sat, 07 Jan 2012 11:51:51 -0500 Received: by iagj37 with SMTP id j37so5048862iag.4 for ; Sat, 07 Jan 2012 08:51:50 -0800 (PST) MIME-Version: 1.0 Received: by 10.43.117.194 with SMTP id fn2mr9651087icc.53.1325955109969; Sat, 07 Jan 2012 08:51:49 -0800 (PST) Received: by 10.42.164.131 with HTTP; Sat, 7 Jan 2012 08:51:49 -0800 (PST) Date: Sat, 7 Jan 2012 08:51:49 -0800 Message-ID: From: Kevin Grover To: gpsd-dev@nongnu.org Content-Type: multipart/mixed; boundary=bcaec5186cbe51609e04b5f2fb5b X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.173 X-Mailman-Approved-At: Sun, 08 Jan 2012 09:14:39 -0500 Subject: [gpsd-dev] Patch to INSTALL (spelling and typos) X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Jan 2012 16:51:53 -0000 --bcaec5186cbe51609e04b5f2fb5b Content-Type: multipart/alternative; boundary=bcaec5186cbe51609a04b5f2fb59 --bcaec5186cbe51609a04b5f2fb59 Content-Type: text/plain; charset=UTF-8 Here's a little patch for INSTALL: a couple of typos and a spelling error. NOTE: I do not subscribe to this list, so I will not see replies. --bcaec5186cbe51609a04b5f2fb59 Content-Type: text/html; charset=UTF-8 Here's a little patch for INSTALL: a couple of typos and a spelling error.

NOTE: I do not subscribe to this list, so I will not see replies.

--bcaec5186cbe51609a04b5f2fb59-- --bcaec5186cbe51609e04b5f2fb5b Content-Type: application/octet-stream; name="0001-Corrected-typos-and-spelling-error.patch" Content-Disposition: attachment; filename="0001-Corrected-typos-and-spelling-error.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gx4vfaw90 RnJvbSBiZTg5MzQ3NWYxYjQ4MzNhMzI0N2RlM2ZmZTMxMGM5ZTkwYWVmY2NlIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiAiS2V2aW4gTy4gR3JvdmVyIiA8a2V2aW5Aa2V2aW5ncm92ZXIu bmV0PgpEYXRlOiBTYXQsIDcgSmFuIDIwMTIgMDg6NDI6MDcgLTA4MDAKU3ViamVjdDogW1BBVENI XSBDb3JyZWN0ZWQgdHlwb3MgYW5kIHNwZWxsaW5nIGVycm9yLgoKLS0tCiBJTlNUQUxMIHwgICAg NiArKystLS0KIDEgZmlsZXMgY2hhbmdlZCwgMyBpbnNlcnRpb25zKCspLCAzIGRlbGV0aW9ucygt KQoKZGlmZiAtLWdpdCBhL0lOU1RBTEwgYi9JTlNUQUxMCmluZGV4IDhmZDIyNGEuLmFhNWNlODAg MTAwNjQ0Ci0tLSBhL0lOU1RBTEwKKysrIGIvSU5TVEFMTApAQCAtMjAsOSArMjAsOSBAQCBhIHNo b3J0IGluaXRpYWwgYnVyc3Qgb2YgYmluYXJ5IGdhcmJhZ2UpLiAgSWYgeW91IGRvbid0IHNlZSB0 aGlzLCB5b3UKIG1heSBoYXZlIE9TLWxldmVsIHByb2JsZW1zIHdpdGggeW91ciBzZXJpYWwgc3Vw cG9ydCwgYnV0IG1vcmUgbGlrZWx5CiBoYXZlIHRoZSB3cm9uZyBkZXZpY2UuICBMb29rIGFnYWlu LgogCi1JZiB5b3UgaGF2ZSB0cm91YmxlIHd1dGggdGhlIHByZWNlZGluZyBzdGVwLCBjaGVjayB5 b3VyIGNhYmxpbmcKK0lmIHlvdSBoYXZlIHRyb3VibGUgd2l0aCB0aGUgcHJlY2VkaW5nIHN0ZXAs IGNoZWNrIHlvdXIgY2FibGluZwogZmlyc3QuICBWZXJpZnkgdGhhdCB0aGUgZGV2aWNlIGlzIGNv bm5lY3RlZCBhbmQgdGhhdCBpdHMgcG93ZXIgTEVECi0oaWYgaXV0IGhhcyBvbmUpIGlzIGxpdC4K KyhpZiBpdCBoYXMgb25lKSBpcyBsaXQuCiAKIElmIHlvdSBzZWVtIHRvIGhhdmUgc29tZSBzb3J0 IG9mIHNlcmlhbC1kZXZpY2UgcHJvYmxlbSwgY2hlY2sgdGhhdAogeW91ciBrZXJuZWwgcHJvcGVy bHkgc3VwcG9ydHMgdGhlIGRldmljZSB5b3UgYXJlIHVzaW5nLiAgRm9yIEdQU2VzCkBAIC04Niw3 ICs4Niw3IEBAIHZhcmlvdXMgYWRkaXRpb25hbCBmZWF0dXJlcyBoYXZlIGFkZGl0aW9uYWwgcHJl cmVxdWlzaXRlczoKIHw9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQogCiBTb21lIG5jdXJzZXMgcGFja2FnZXMg Y29tbnRhaW4gdGhlIHRlcm1pbmZvIGxpYnJhcnk7IHNvbWUgYnJlYWsgaXQgb3V0Ci1zZXBlcmF0 ZWx5IGFzIGxpYnRpbmZvNSBvciBsaWJ0aW5mby4KK3NlcGFyYXRlbHkgYXMgbGlidGluZm81IG9y IGxpYnRpbmZvLgogCiBUaGUgUHl0aG9uIGNvZGUgaW4gR1BTRCBpcyBhY3R1YWxseSBjb21wYXRp YmxlIGJhY2sgdG8gUHl0aG9uIDIuNCBleGNlcHQgdGhhdAogeW91IG5lZWQgZWl0aGVyIHRoZSBq c29uIGxpYnJhcnkgbW9kdWxlIGZyb20gMi42IG9yIHRoZSBmdW5jdGlvbmFsbHkKLS0gCjEuNy41 LjQKCg== --bcaec5186cbe51609e04b5f2fb5b-- From MAILER-DAEMON Mon Jan 09 12:25:11 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RkIy6-0000Uq-VQ for mharc-gpsd-dev@gnu.org; Mon, 09 Jan 2012 12:25:10 -0500 Received: from eggs.gnu.org ([140.186.70.92]:59830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkIxz-0000Pa-LJ for gpsd-dev@nongnu.org; Mon, 09 Jan 2012 12:25:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkIxy-0000D8-E5 for gpsd-dev@nongnu.org; Mon, 09 Jan 2012 12:25:03 -0500 Received: from nm19.bullet.mail.sp2.yahoo.com ([98.139.91.89]:40728) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RkIxy-0000CY-05 for gpsd-dev@nongnu.org; Mon, 09 Jan 2012 12:25:02 -0500 Received: from [98.139.91.63] by nm19.bullet.mail.sp2.yahoo.com with NNFMP; 09 Jan 2012 17:25:00 -0000 Received: from [208.71.42.202] by tm3.bullet.mail.sp2.yahoo.com with NNFMP; 09 Jan 2012 17:25:00 -0000 Received: from [127.0.0.1] by smtp213.mail.gq1.yahoo.com with NNFMP; 09 Jan 2012 17:25:00 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1326129900; bh=w+PdTnHL6EZy6Dwi4QD6KpGQeMsDJsdcezZgjccPe+I=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Message-ID:Subject:From:To:Date:Content-Type:X-Mailer:Content-Transfer-Encoding:Mime-Version; b=4cbY5wK8BgNAhARXSGz1W2GNc3z5WWgsBH7nUkte49oD+NcSh3z35A5wTmaUNLfy48zDoFh8l+E85osODRw0/1BTnu7jNECB2I+kWE5IBu8QJSOTlbkX+Stv93vlKmImrQ3bMSDdIHCe4Br+2cH3ryEVd2xcFXhxrIHkINGZhJI= X-Yahoo-Newman-Id: 540890.86782.bm@smtp213.mail.gq1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: lcf8diEVM1m_50WhjeunJwiACg4ofLuGsomQDepFfMjIN1n 7cUvS5PLpPCQer6Fk9f_RksDtK1qLvlg2a8BrPvqdXF6LFGDWpXcJFGlV73u nM7jvk.n.G5Ym7pEnj4YS0OobCqYjc.SuZyyyy1DhYa0lkiBOJihpOuFJrKc zcEniI3lip1i2IEkV_NV1h8YBOENVB1K3UxDbbAiAhmLkJ6nRVlQKIklgWWD U6bu6Pfnv7IzfqiNErhrMnnMd6c7aiTVBnvrh3Z_i8gaNsVURTlSnA3fY_0b f.lIo.nAz5bX9PwwffDnbxN7yET.fmArBO9r5IvLoean5PCLwAyhDBsBk6Qd Tspt9a_ualZ2riQvSiVCyzUPj4ufPoC_Kx8ApGEJxbJKRN_hp14.Iq97rfu2 b12KGug-- X-Yahoo-SMTP: GQBZFNiswBBj4d3U4mCBvx.xTw-- Received: from [192.168.0.13] (prahal@88.166.184.3 with plain) by smtp213.mail.gq1.yahoo.com with SMTP; 09 Jan 2012 09:24:59 -0800 PST Message-ID: <1326129897.17780.2.camel@penelope> From: Alban Browaeys To: gpsd-dev@nongnu.org Date: Mon, 09 Jan 2012 18:24:57 +0100 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.3.4 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 98.139.91.89 Subject: [gpsd-dev] [PATCH] gpscat: fix incorrect test againt rfcomm for bluetooth address X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2012 17:25:09 -0000 We feed arguments[0] to the bluetooth socket so this has to be the address and cannot contains "rfcomm" string. --- gpscat | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gpscat b/gpscat index f3903fa..a4b8ed3 100755 --- a/gpscat +++ b/gpscat @@ -70,12 +70,12 @@ if __name__ == '__main__': printusage() raise SystemExit, 1 - if "rfcomm" in arguments[0]: # Bluetooth special case + if arguments[0][0] == '/': # Ordinary device + tty = os.open(arguments[0], os.O_RDWR) + else: # Bluetooth special case s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) s.connect((arguments[0], 1)) tty = s.fileno() - else: # Ordinary device - tty = os.open(arguments[0], os.O_RDWR) if speed != None: (iflag, oflag, cflag, lflag, ispeed, ospeed, cc) = termios.tcgetattr(tty) -- 1.7.8.2 From MAILER-DAEMON Mon Jan 09 12:31:32 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RkJ4G-0002hb-Uo for mharc-gpsd-dev@gnu.org; Mon, 09 Jan 2012 12:31:32 -0500 Received: from eggs.gnu.org ([140.186.70.92]:47957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkJ4A-0002gw-TX for gpsd-dev@nongnu.org; Mon, 09 Jan 2012 12:31:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkJ49-0001RJ-Pi for gpsd-dev@nongnu.org; Mon, 09 Jan 2012 12:31:26 -0500 Received: from nm38-vm0.bullet.mail.ne1.yahoo.com ([98.138.229.144]:48107) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RkJ49-0001R9-Kb for gpsd-dev@nongnu.org; Mon, 09 Jan 2012 12:31:25 -0500 Received: from [98.138.90.48] by nm38.bullet.mail.ne1.yahoo.com with NNFMP; 09 Jan 2012 17:31:24 -0000 Received: from [98.138.226.131] by tm1.bullet.mail.ne1.yahoo.com with NNFMP; 09 Jan 2012 17:31:24 -0000 Received: from [127.0.0.1] by smtp218.mail.ne1.yahoo.com with NNFMP; 09 Jan 2012 17:31:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1326130284; bh=kMqtmnCq7/a9B1bLKIwi2zrNTvfiE310TfMkvFSz4Jw=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Message-ID:Subject:From:To:Date:Content-Type:X-Mailer:Content-Transfer-Encoding:Mime-Version; b=b9p+KvFiXaCMftCeTa6mVIaQZlxKgXF0eXropKtAKv1nZeDv2nfIr1hAHMgFdSfOOS5HVrFgCKEt1A9G/H4MYKe6ry6ECKeqddQ5iCViQIOojewaQFYiKa1r5IGFr6UbbodL0qo7UWdXME65XYrXf6HohNxMl11BRvZJstRvE44= X-Yahoo-Newman-Id: 148514.85101.bm@smtp218.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: vv8EK8wVM1l.y1jDs8wjsrLupf50xJ1sMiKxlCZ7cXLLE_V CEgSkiyk690IZE121TLIa.ThzNqUvdKgVRL5MnhLJrEmQogx6jzd1Zs8AYDC 4vcG3.98.tFLk_0.QMaXiY.SPF33kS1AOofnXcSvAfMLeFHn.OUJPo2nKCsN WOD6W6P5xH021VYbmVuNo0a7XVot9FloLJ9IGh8MAu__.3F2ZeaXI6nYmbZV S8wEsOHSn_TPmEpHugSkNibUSSOx3yddPdP2_HdhO0INqiHhdeVdGCZTsE5A V._lg2Qog1YFjr8y60mKTtjlY5UgkAzXzBMSjiYd75ebgA_jZNykBvUsdlIr LKPYGwtD2drAMScV44xDNWPiFOwa7vWLwiUI84EXDFliMXrg8DXXCXFNsIlV jmPiItA-- X-Yahoo-SMTP: GQBZFNiswBBj4d3U4mCBvx.xTw-- Received: from [192.168.0.13] (prahal@88.166.184.3 with plain) by smtp218.mail.ne1.yahoo.com with SMTP; 09 Jan 2012 09:31:23 -0800 PST Message-ID: <1326130282.17780.8.camel@penelope> From: Alban Browaeys To: gpsd-dev@nongnu.org Date: Mon, 09 Jan 2012 18:31:22 +0100 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.3.4 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 98.138.229.144 Subject: [gpsd-dev] geoclue/gnome-bluetooth integration X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2012 17:31:32 -0000 I started a local update to gecolue-gpsd and adding a long standing missing feature for to integrate with gnome-bluetooth/geoclue. That is add the ability to add a bluetooth device to gpsd when it is added by the user. I seem to have lost all hope to be able to be able to let the user be able to register a new device to gpsd . Ie it seems the only way is to talk to the gpsd.sock which is by the manpage told to be root only. Does this means gpsd is designed to force admins to provide root access to its users owning a bluetooth device ? Best regards, Alban From MAILER-DAEMON Mon Jan 09 13:19:21 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RkJoX-00081L-II for mharc-gpsd-dev@gnu.org; Mon, 09 Jan 2012 13:19:21 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkJoO-0007z6-R8 for gpsd-dev@nongnu.org; Mon, 09 Jan 2012 13:19:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkJoK-0008WH-SE for gpsd-dev@nongnu.org; Mon, 09 Jan 2012 13:19:12 -0500 Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5]:50818 helo=snark.thyrsus.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkJoK-0008VM-Pf for gpsd-dev@nongnu.org; Mon, 09 Jan 2012 13:19:08 -0500 Received: by snark.thyrsus.com (Postfix, from userid 1000) id ED09B428F0; Mon, 9 Jan 2012 13:18:57 -0500 (EST) Date: Mon, 9 Jan 2012 13:18:57 -0500 From: "Eric S. Raymond" To: "Michael R. Davis" Message-ID: <20120109181857.GB30553@thyrsus.com> References: <2091470581-1324571873-cardhu_decombobulator_blackberry.rim.net-1957528673-@b16.c6.bise6.blackberry> <3213c62edfd9bf14a5c562f34633db9e@presslab.us> <1324960849.15307.YahooMailNeo@web32505.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1324960849.15307.YahooMailNeo@web32505.mail.mud.yahoo.com> Organization: Eric Conspiracy Secret Labs X-Eric-Conspiracy: There is no conspiracy User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.162.243.5 Cc: "gpsd-dev@nongnu.org" , Ryan Press Subject: Re: [gpsd-dev] Net::GPSD3 and POLL X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: esr@thyrsus.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2012 18:19:20 -0000 Michael R. Davis : > Ryan, > I see that the POLL API has changed and was not backwards compatible. That's why the feature was marked excperimental. I knew I might have to m= ess witgh it. > I also need to review all of the datetime fields as the API changed > the "time" value format from epoch to W3C in different objects over > different versions without changing the key name.=A0 I was careful to preserve backwards compatibility here, however. The library eads the old format as well as the new. --=20 Eric S. Raymond From MAILER-DAEMON Tue Jan 10 03:25:57 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RkX1p-0003CK-QO for mharc-gpsd-dev@gnu.org; Tue, 10 Jan 2012 03:25:57 -0500 Received: from eggs.gnu.org ([140.186.70.92]:41156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkX1i-00039E-Ak for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 03:25:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkX1a-0004EL-Le for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 03:25:50 -0500 Received: from mail.recluse.de ([217.196.146.213]:47495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkX1a-0004Dl-EQ for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 03:25:42 -0500 Received: from mail.recluse.de (localhost [127.0.0.1]) by mail.recluse.de (Postfix) with ESMTP id BFD1925F30 for ; Tue, 10 Jan 2012 09:25:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at recluse.de Received: from mail.recluse.de ([127.0.0.1]) by mail.recluse.de (mail.recluse.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tPhpERgUteMQ for ; Tue, 10 Jan 2012 09:25:37 +0100 (CET) Received: from [192.168.1.34] (congw.dc1.conova.com [217.196.145.250]) by mail.recluse.de (Postfix) with ESMTPSA id 5B9E925F1B for ; Tue, 10 Jan 2012 09:25:37 +0100 (CET) Message-ID: <4F0BF601.1070400@bzed.de> Date: Tue, 10 Jan 2012 09:25:37 +0100 From: Bernd Zeimetz User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 MIME-Version: 1.0 To: gpsd-dev@nongnu.org References: <1326129897.17780.2.camel@penelope> In-Reply-To: <1326129897.17780.2.camel@penelope> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 217.196.146.213 Subject: Re: [gpsd-dev] [PATCH] gpscat: fix incorrect test againt rfcomm for bluetooth address X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2012 08:25:55 -0000 On 01/09/2012 06:24 PM, Alban Browaeys wrote: > We feed arguments[0] to the bluetooth socket so this has to be > the address and cannot contains "rfcomm" string. > --- > gpscat | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/gpscat b/gpscat > index f3903fa..a4b8ed3 100755 > --- a/gpscat > +++ b/gpscat > @@ -70,12 +70,12 @@ if __name__ == '__main__': > printusage() > raise SystemExit, 1 > > - if "rfcomm" in arguments[0]: # Bluetooth special case > + if arguments[0][0] == '/': # Ordinary device Just because a path starts with / we should not assume that we have an ordinary device here. Device nodes could be everywhere in theory, and a path might be relative. > + tty = os.open(arguments[0], os.O_RDWR) > + else: # Bluetooth special case There should be a better way to detect if a device is a bluetooth device imho. Just assuming that all non-"ordinary" devices are bluetooth devices sounds wrong. I guess we'll have other weird devices one day. > s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) > s.connect((arguments[0], 1)) > tty = s.fileno() > - else: # Ordinary device > - tty = os.open(arguments[0], os.O_RDWR) > > if speed != None: > (iflag, oflag, cflag, lflag, ispeed, ospeed, cc) = termios.tcgetattr(tty) -- Bernd Zeimetz Debian GNU/Linux Developer http://bzed.de http://www.debian.org GPG Fingerprints: ECA1 E3F2 8E11 2432 D485 DD95 EB36 171A 6FF9 435F From MAILER-DAEMON Tue Jan 10 03:27:33 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RkX3M-0003NV-Vz for mharc-gpsd-dev@gnu.org; Tue, 10 Jan 2012 03:27:32 -0500 Received: from eggs.gnu.org ([140.186.70.92]:41477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkX3G-0003Ma-2P for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 03:27:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkX3E-0004OQ-TN for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 03:27:26 -0500 Received: from mail.recluse.de ([217.196.146.213]:43407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkX3E-0004OF-K5 for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 03:27:24 -0500 Received: from mail.recluse.de (localhost [127.0.0.1]) by mail.recluse.de (Postfix) with ESMTP id DFCBA25F30 for ; Tue, 10 Jan 2012 09:27:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at recluse.de Received: from mail.recluse.de ([127.0.0.1]) by mail.recluse.de (mail.recluse.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zJPzluPfhg4x for ; Tue, 10 Jan 2012 09:27:22 +0100 (CET) Received: from [192.168.1.34] (congw.dc1.conova.com [217.196.145.250]) by mail.recluse.de (Postfix) with ESMTPSA id 6BB4D25F1B for ; Tue, 10 Jan 2012 09:27:22 +0100 (CET) Message-ID: <4F0BF66A.3080008@bzed.de> Date: Tue, 10 Jan 2012 09:27:22 +0100 From: Bernd Zeimetz User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 MIME-Version: 1.0 To: gpsd-dev@nongnu.org References: <1326130282.17780.8.camel@penelope> In-Reply-To: <1326130282.17780.8.camel@penelope> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 217.196.146.213 Subject: Re: [gpsd-dev] geoclue/gnome-bluetooth integration X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2012 08:27:31 -0000 On 01/09/2012 06:31 PM, Alban Browaeys wrote: > I started a local update to gecolue-gpsd and adding a long standing > missing feature for to integrate with gnome-bluetooth/geoclue. That is > add the ability to add a bluetooth device to gpsd when it is added by > the user. > > I seem to have lost all hope to be able to be able to let the user be > able to register a new device to gpsd . Ie it seems the only way is to > talk to the gpsd.sock which is by the manpage told to be root only. > Does this means gpsd is designed to force admins to provide root access > to its users owning a bluetooth device ? Unix permissions apply to unix sockets and it is possible to give gpsd a specific group to run as. Members of that group should be able to write to the socket... (not tested, though). -- Bernd Zeimetz Debian GNU/Linux Developer http://bzed.de http://www.debian.org GPG Fingerprints: ECA1 E3F2 8E11 2432 D485 DD95 EB36 171A 6FF9 435F From MAILER-DAEMON Tue Jan 10 13:11:24 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RkgAO-0005dR-3x for mharc-gpsd-dev@gnu.org; Tue, 10 Jan 2012 13:11:24 -0500 Received: from eggs.gnu.org ([140.186.70.92]:58225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkgAI-0005cP-8J for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 13:11:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkgAE-00080a-Uc for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 13:11:18 -0500 Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5]:41318 helo=snark.thyrsus.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkgAE-00080D-MM for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 13:11:14 -0500 Received: by snark.thyrsus.com (Postfix, from userid 1000) id 7952F42A46; Tue, 10 Jan 2012 13:11:12 -0500 (EST) Date: Tue, 10 Jan 2012 13:11:12 -0500 From: "Eric S. Raymond" To: Bernd Zeimetz Message-ID: <20120110181112.GB6631@thyrsus.com> References: <1326129897.17780.2.camel@penelope> <4F0BF601.1070400@bzed.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F0BF601.1070400@bzed.de> Organization: Eric Conspiracy Secret Labs X-Eric-Conspiracy: There is no conspiracy User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.162.243.5 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] [PATCH] gpscat: fix incorrect test againt rfcomm for bluetooth address X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: esr@thyrsus.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2012 18:11:22 -0000 Bernd Zeimetz : > There should be a better way to detect if a device is a bluetooth device > imho. Just assuming that all non-"ordinary" devices are bluetooth > devices sounds wrong. I guess we'll have other weird devices one day. I agree with Bernd's objection. Find a better way. -- Eric S. Raymond From MAILER-DAEMON Tue Jan 10 13:20:51 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RkgJX-0000ay-6m for mharc-gpsd-dev@gnu.org; Tue, 10 Jan 2012 13:20:51 -0500 Received: from eggs.gnu.org ([140.186.70.92]:57205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkgJR-0000WV-Bt for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 13:20:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkgJP-0003aN-BN for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 13:20:45 -0500 Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5]:41365 helo=snark.thyrsus.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkgJP-0003Zi-7e for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 13:20:43 -0500 Received: by snark.thyrsus.com (Postfix, from userid 1000) id 43AFE42A46; Tue, 10 Jan 2012 13:20:39 -0500 (EST) Date: Tue, 10 Jan 2012 13:20:39 -0500 From: "Eric S. Raymond" To: Alban Browaeys Message-ID: <20120110182039.GC6631@thyrsus.com> References: <1326130282.17780.8.camel@penelope> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1326130282.17780.8.camel@penelope> Organization: Eric Conspiracy Secret Labs X-Eric-Conspiracy: There is no conspiracy User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.162.243.5 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] geoclue/gnome-bluetooth integration X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: esr@thyrsus.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2012 18:20:50 -0000 Alban Browaeys : > I seem to have lost all hope to be able to be able to let the user be > able to register a new device to gpsd . Ie it seems the only way is to > talk to the gpsd.sock which is by the manpage told to be root only. > Does this means gpsd is designed to force admins to provide root access > to its users owning a bluetooth device ? No. The problem is security. The GPSD control socket can be used to do things that are unsafe; making it world-writeable would allow denial-of-service attacks. Up to now, root-only access has been acceptable because there were only two major use cases. Usually, devices are USB and set up by hotplug. Serial devices have to be set up by hand, so the assumption is that gpsc is run by hand with a command-line device, bypassing the control socket. I recognize from what you say that Bluetooth presents a design problem that will require us to change our model somewhat. Does the bluetooth program that wants to use this socket run in some sort of admin or tty group? If so, the solution might be as simple as changing the socket ownership. -- Eric S. Raymond From MAILER-DAEMON Tue Jan 10 15:44:55 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RkiYx-0002i5-QB for mharc-gpsd-dev@gnu.org; Tue, 10 Jan 2012 15:44:55 -0500 Received: from eggs.gnu.org ([140.186.70.92]:51078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkiYv-0002hy-FU for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 15:44:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkiYq-0005z1-F1 for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 15:44:53 -0500 Received: from nm8-vm0.bullet.mail.sp2.yahoo.com ([98.139.91.194]:36030) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RkiYq-0005yv-3m for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 15:44:48 -0500 Received: from [98.139.91.66] by nm8.bullet.mail.sp2.yahoo.com with NNFMP; 10 Jan 2012 20:44:46 -0000 Received: from [208.71.42.207] by tm6.bullet.mail.sp2.yahoo.com with NNFMP; 10 Jan 2012 20:44:46 -0000 Received: from [127.0.0.1] by smtp218.mail.gq1.yahoo.com with NNFMP; 10 Jan 2012 20:44:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1326228286; bh=Q0qrVuRFbR/7UhrPf6cgDMx6h3454YRRD+I9XZc6zTs=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References:Content-Type:X-Mailer:Content-Transfer-Encoding:Mime-Version; b=sfTde9tkih8MiCQ9DNfXSmFKYyViKda3LcOjcBc4cpeeg2DdmdQCDyEu5uLu3U/NMKmvYEZ0FjQrGD6kctYVT2/QhpgUGdG46qCBQ5m++K2KCBaTUbAYY9IQzLNoHmjplEW1KNReKSCHWct7oMoy61p1lO/9psWXnRnJo5l32Po= X-Yahoo-Newman-Id: 516910.92223.bm@smtp218.mail.gq1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: YuMbC58VM1mYUDooeEQc.9.94_ZXyT37Q0tpRdhID1HSrdI Ky2kFHrpb8aYEuR81RMYoHEa5QcPjdC3YHQgIC8YDL_N540eFekfnGQ7_M8W ivhKFjV.n6w7QI6JSRhKLkqfnwzuz1Q.rK.H0780oYXcXfLEXFEk0zGGkZR6 NArx0j9paCkdEq_hiJUc8tEPdY.69UobMGUx4CBzYmutsf44KpIIG_RFKYbO GXeXrdxWD3RVXflRi5OKPh.rknD5MLKAGltNLycvRCiZ7s5DPWnSdSqKNWRq o8A5fvBfIzKIQE4aF_KREyJsOUzx5nYKwvrkY4BVb0behUPaWK6pAPYcsqFJ 36xTEjPxssuNWMhpn.5IxYCdSKRAr65BzvPWAapBADNLM.TEevxjuGCgKuNh jYCE6nQ-- X-Yahoo-SMTP: GQBZFNiswBBj4d3U4mCBvx.xTw-- Received: from [192.168.0.13] (prahal@88.166.184.3 with plain) by smtp218.mail.gq1.yahoo.com with SMTP; 10 Jan 2012 12:44:45 -0800 PST Message-ID: <1326228284.17780.16.camel@penelope> From: Alban Browaeys To: esr@thyrsus.com Date: Tue, 10 Jan 2012 21:44:44 +0100 In-Reply-To: <20120110182039.GC6631@thyrsus.com> References: <1326130282.17780.8.camel@penelope> <20120110182039.GC6631@thyrsus.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.3.4 Content-Transfer-Encoding: 8bit Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 98.139.91.194 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] geoclue/gnome-bluetooth integration X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2012 20:44:54 -0000 Le mardi 10 janvier 2012 à 13:20 -0500, Eric S. Raymond a écrit : > I recognize from what you say that Bluetooth presents a design problem that > will require us to change our model somewhat. Does the bluetooth program > that wants to use this socket run in some sort of admin or tty group? If > so, the solution might be as simple as changing the socket ownership. I do not know if we can rely on any group ownership. The bluetooth manager is part of the standard user session. As its geoclue plugin and the gpsd gecolue plugin. The issue is to avoid the need for the admin to give the user the admin/root password (which could be worst than gpsd behing compromised knowing it is not running as root and we would require the user to be able to execute anything on the system to avoid it to get compromised ./ ). Alban From MAILER-DAEMON Tue Jan 10 23:38:02 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rkpwo-0003cH-2H for mharc-gpsd-dev@gnu.org; Tue, 10 Jan 2012 23:38:02 -0500 Received: from eggs.gnu.org ([140.186.70.92]:33910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rkpwl-0003cB-Kp for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 23:38:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rkpwk-00078c-Qm for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 23:37:59 -0500 Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5]:44549 helo=snark.thyrsus.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rkpwk-00078Y-OW for gpsd-dev@nongnu.org; Tue, 10 Jan 2012 23:37:58 -0500 Received: by snark.thyrsus.com (Postfix, from userid 1000) id 496E142A47; Tue, 10 Jan 2012 23:37:56 -0500 (EST) Date: Tue, 10 Jan 2012 23:37:56 -0500 From: "Eric S. Raymond" To: Alban Browaeys Message-ID: <20120111043756.GB11267@thyrsus.com> References: <1326130282.17780.8.camel@penelope> <20120110182039.GC6631@thyrsus.com> <1326228284.17780.16.camel@penelope> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1326228284.17780.16.camel@penelope> Organization: Eric Conspiracy Secret Labs X-Eric-Conspiracy: There is no conspiracy User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.162.243.5 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] geoclue/gnome-bluetooth integration X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: esr@thyrsus.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 04:38:00 -0000 Alban Browaeys : > I do not know if we can rely on any group ownership. The bluetooth > manager is part of the standard user session. As its geoclue plugin and > the gpsd gecolue plugin. We might need to *create* a group then. > The issue is to avoid the need for the admin to give the user the > admin/root password (which could be worst than gpsd behing compromised > knowing it is not running as root and we would require the user to be > able to execute anything on the system to avoid it to get compromised ./ > ). I understand the issue. I'm now looking for the least obtrusive way to solve it. -- Eric S. Raymond From MAILER-DAEMON Wed Jan 11 05:59:31 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rkvtz-0005P3-EF for mharc-gpsd-dev@gnu.org; Wed, 11 Jan 2012 05:59:31 -0500 Received: from eggs.gnu.org ([140.186.70.92]:39205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rkvts-0005OB-Kg for gpsd-dev@nongnu.org; Wed, 11 Jan 2012 05:59:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rkvto-0002hF-8n for gpsd-dev@nongnu.org; Wed, 11 Jan 2012 05:59:24 -0500 Received: from mail.recluse.de ([217.196.146.213]:41845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rkvto-0002h8-3C for gpsd-dev@nongnu.org; Wed, 11 Jan 2012 05:59:20 -0500 Received: from mail.recluse.de (localhost [127.0.0.1]) by mail.recluse.de (Postfix) with ESMTP id 1952B25F71 for ; Wed, 11 Jan 2012 11:59:17 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at recluse.de Received: from mail.recluse.de ([127.0.0.1]) by mail.recluse.de (mail.recluse.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j5XdoUjCkKCS for ; Wed, 11 Jan 2012 11:59:15 +0100 (CET) Received: from [192.168.1.34] (congw.dc1.conova.com [217.196.145.250]) by mail.recluse.de (Postfix) with ESMTPSA id 97FC225F3C for ; Wed, 11 Jan 2012 11:59:15 +0100 (CET) Message-ID: <4F0D6B83.2030105@bzed.de> Date: Wed, 11 Jan 2012 11:59:15 +0100 From: Bernd Zeimetz User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 MIME-Version: 1.0 To: gpsd-dev@nongnu.org References: <1326130282.17780.8.camel@penelope> <20120110182039.GC6631@thyrsus.com> <1326228284.17780.16.camel@penelope> <20120111043756.GB11267@thyrsus.com> In-Reply-To: <20120111043756.GB11267@thyrsus.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 217.196.146.213 Subject: Re: [gpsd-dev] geoclue/gnome-bluetooth integration X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 10:59:30 -0000 On 01/11/2012 05:37 AM, Eric S. Raymond wrote: > Alban Browaeys : >> I do not know if we can rely on any group ownership. The bluetooth >> manager is part of the standard user session. As its geoclue plugin and >> the gpsd gecolue plugin. > > We might need to *create* a group then. I think that is an issue which needs to be solved in a distribution. Allowing the gid gpsd runs as to access the socket should net be an issue. Addings users to it or running other daemons with according permissions is also nothing gpsd needs to solve. >> The issue is to avoid the need for the admin to give the user the >> admin/root password (which could be worst than gpsd behing compromised >> knowing it is not running as root and we would require the user to be >> able to execute anything on the system to avoid it to get compromised ./ >> ). > > I understand the issue. I'm now looking for the least obtrusive way to > solve it. -- Bernd Zeimetz Debian GNU/Linux Developer http://bzed.de http://www.debian.org GPG Fingerprints: ECA1 E3F2 8E11 2432 D485 DD95 EB36 171A 6FF9 435F From MAILER-DAEMON Wed Jan 11 11:00:31 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rl0bH-0002ql-EC for mharc-gpsd-dev@gnu.org; Wed, 11 Jan 2012 11:00:31 -0500 Received: from eggs.gnu.org ([140.186.70.92]:36472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rl0bA-0002pM-QH for gpsd-dev@nongnu.org; Wed, 11 Jan 2012 11:00:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rl0b1-00088a-1p for gpsd-dev@nongnu.org; Wed, 11 Jan 2012 11:00:24 -0500 Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5]:48318 helo=snark.thyrsus.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rl0b0-00088U-VS for gpsd-dev@nongnu.org; Wed, 11 Jan 2012 11:00:15 -0500 Received: by snark.thyrsus.com (Postfix, from userid 1000) id 5BCA342A47; Wed, 11 Jan 2012 11:00:10 -0500 (EST) Date: Wed, 11 Jan 2012 11:00:10 -0500 From: "Eric S. Raymond" To: Bernd Zeimetz Message-ID: <20120111160010.GA24337@thyrsus.com> References: <1326130282.17780.8.camel@penelope> <20120110182039.GC6631@thyrsus.com> <1326228284.17780.16.camel@penelope> <20120111043756.GB11267@thyrsus.com> <4F0D6B83.2030105@bzed.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F0D6B83.2030105@bzed.de> Organization: Eric Conspiracy Secret Labs X-Eric-Conspiracy: There is no conspiracy User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.162.243.5 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] geoclue/gnome-bluetooth integration X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: esr@thyrsus.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 16:00:29 -0000 Bernd Zeimetz : > I think that is an issue which needs to be solved in a distribution. > Allowing the gid gpsd runs as to access the socket should net be an > issue. Addings users to it or running other daemons with according > permissions is also nothing gpsd needs to solve. Good point. I will, however, find (or create) notes for packagers to drop a hint about this. -- Eric S. Raymond From MAILER-DAEMON Thu Jan 12 11:46:58 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlNnm-0004vi-GD for mharc-gpsd-dev@gnu.org; Thu, 12 Jan 2012 11:46:58 -0500 Received: from eggs.gnu.org ([140.186.70.92]:43292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlNng-0004qP-27 for gpsd-dev@nongnu.org; Thu, 12 Jan 2012 11:46:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlNnb-0003b9-02 for gpsd-dev@nongnu.org; Thu, 12 Jan 2012 11:46:52 -0500 Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5]:59132 helo=snark.thyrsus.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlNna-0003b2-Ty; Thu, 12 Jan 2012 11:46:46 -0500 Received: by snark.thyrsus.com (Postfix, from userid 1000) id DAEB542A47; Thu, 12 Jan 2012 11:46:40 -0500 (EST) From: esr@thyrsus.com (Eric S. Raymond) To: gpsd-dev@nongnu.org, gpsd-users@nongnu.org Message-Id: <20120112164640.DAEB542A47@snark.thyrsus.com> Date: Thu, 12 Jan 2012 11:46:40 -0500 (EST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.162.243.5 Subject: [gpsd-dev] 3.4 is shipped X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2012 16:46:56 -0000 Mainly packaging fixes in this release. I've received some code to support NMEA2000 in cooperation with a kernel driver that makes CAN packets available on a socket. That is likely to be the major feature in 3.5. -- Eric S. Raymond All forms of government are pernicious, including good government. -- Edward Abbey From MAILER-DAEMON Fri Jan 13 12:21:02 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlkoH-0006RA-VN for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 12:21:01 -0500 Received: from eggs.gnu.org ([140.186.70.92]:46578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlkoC-0006Ns-09 for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 12:21:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rlko6-0005Wl-0N for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 12:20:55 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:42622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlko5-0005Wg-SE for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 12:20:49 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 4DDB31B4003; Fri, 13 Jan 2012 17:20:47 +0000 (UTC) From: Mike Frysinger To: gpsd-dev@nongnu.org Date: Fri, 13 Jan 2012 12:20:47 -0500 Message-Id: <1326475247-19186-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.8.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Cc: Manuel Lauss Subject: [gpsd-dev] [PATCH] serial: use cfgetispeed helpers X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 17:21:00 -0000 From: Manuel Lauss Rather than poking c_ispeed directly, use the cfgetispeed helper. This is part of POSIX, and we already use cfsetispeed, so there shouldn't be any portability issues here. Signed-off-by: Manuel Lauss Signed-off-by: Mike Frysinger --- serial.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-) diff --git a/serial.c b/serial.c index c1464dd..8eb03ce 100644 --- a/serial.c +++ b/serial.c @@ -594,13 +594,8 @@ void gpsd_close(struct gps_device_t *session) * them the first time. Economical, and avoids tripping over an * obscure Linux 2.6 kernel bug that disables threaded * ioctl(TIOCMWAIT) on a device after tcsetattr() is called. - * - * Unfortunately the termios struct doesn't have c_ispeed/c_ospeed - * on all architectures. Its missing on sparc, mips/mispel and hurd-i386 at least. */ -#if defined(_HAVE_STRUCT_TERMIOS_C_ISPEED) - if (session->ttyset_old.c_ispeed != session->ttyset.c_ispeed || (session->ttyset_old.c_cflag & CSTOPB) != (session->ttyset.c_cflag & CSTOPB)) { -#endif + if (cfgetispeed(&session->ttyset_old) != cfgetispeed(&session->ttyset) || (session->ttyset_old.c_cflag & CSTOPB) != (session->ttyset.c_cflag & CSTOPB)) { /*@ ignore @*/ (void)cfsetispeed(&session->ttyset_old, (speed_t) session->gpsdata.dev.baudrate); @@ -609,9 +604,7 @@ void gpsd_close(struct gps_device_t *session) /*@ end @*/ (void)tcsetattr(session->gpsdata.gps_fd, TCSANOW, &session->ttyset_old); -#if defined(_HAVE_STRUCT_TERMIOS_C_ISPEED) } -#endif gpsd_report(LOG_SPIN, "close(%d) in gpsd_close(%s)\n", session->gpsdata.gps_fd, session->gpsdata.dev.path); (void)close(session->gpsdata.gps_fd); -- 1.7.8.3 From MAILER-DAEMON Fri Jan 13 12:21:15 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlkoV-0006aI-2q for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 12:21:15 -0500 Received: from eggs.gnu.org ([140.186.70.92]:46627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlkoR-0006Vr-MB for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 12:21:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlkoM-0005Xn-Oz for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 12:21:11 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:42674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlkoM-0005Xi-Ea for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 12:21:06 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 9889C1B4033 for ; Fri, 13 Jan 2012 17:21:05 +0000 (UTC) From: Mike Frysinger To: gpsd-dev@nongnu.org Date: Fri, 13 Jan 2012 12:21:05 -0500 Message-Id: <1326475265-19464-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.8.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Subject: [gpsd-dev] [PATCH] gpsmon: always link with -lm X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 17:21:13 -0000 Since the gpsmon pkg uses math funcs itself (and not just via libgps), we need to link in -lm for the app. Signed-off-by: Mike Frysinger --- SConstruct | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/SConstruct b/SConstruct index 68bf367..a5249c1 100644 --- a/SConstruct +++ b/SConstruct @@ -851,7 +851,7 @@ gpsdctl = env.Program('gpsdctl', ['gpsdctl.c'], parse_flags=gpslibs) env.Depends(gpsdctl, compiled_gpslib) gpsmon = env.Program('gpsmon', gpsmon_sources, - parse_flags=gpsdlibs + ncurseslibs) + parse_flags=gpsdlibs + ncurseslibs + ['-lm']) env.Depends(gpsmon, [compiled_gpsdlib, compiled_gpslib]) gpspipe = env.Program('gpspipe', ['gpspipe.c'], parse_flags=gpslibs) -- 1.7.8.3 From MAILER-DAEMON Fri Jan 13 16:07:06 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RloL4-0007nO-Hn for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 16:07:06 -0500 Received: from eggs.gnu.org ([140.186.70.92]:47618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RloL0-0007mK-Pw for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 16:07:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RloKz-0007Pl-Pq for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 16:07:02 -0500 Received: from moutng.kundenserver.de ([212.227.17.8]:60270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RloKz-0007Ok-Dt for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 16:07:01 -0500 Received: from obiwan.localnet (p549BBF2F.dip.t-dialin.net [84.155.191.47]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MNAPk-1RjaLd0il6-006byC; Fri, 13 Jan 2012 22:06:53 +0100 From: Eckhart =?ISO-8859-1?Q?W=F6rner?= To: gpsd-dev@nongnu.org Date: Fri, 13 Jan 2012 22:06:52 +0100 Message-ID: <3587273.FZPhh6N4pi@obiwan> User-Agent: KMail/4.8 rc2 (Linux/3.2.0-8-generic; KDE/4.7.97; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart16583279.x24d0EroJ1" Content-Transfer-Encoding: 7Bit X-Provags-ID: V02:K0:eJxfN+ILjPA7v0GCFNkIWvRuTplCXaOl8hYMpGmn+ci GJ0GXtbCfaP5SjLt4Xw1N1Jdi0YfbowfvPNEU66nqeIA9r5mCM 0UsF2tXN45nlSmuKSx3ozxUCILkGYfb+/8/h2nTCjtR+GfjQHc K09uzF7PA7njyLDIuPHpcnTjSttJeOKba86PFIntFvmeLjTa27 ZSxL6bK3+fa26J3j3COhRnWOE3hpDMbs0+NkVJbASx1yBPJfg2 0zxa1KcJqPZ403QeKp/Qj5puH6EzSoRz87QdDf0zdMDuSNSiK0 l/UCk3RlnkQcV3SW8sTk/W5sn3DURrWO+Jg04/Rw10hcK+sMKU ZpKmcE1LS1UEifTVb+ak= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.8 Subject: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 21:07:04 -0000 --nextPart16583279.x24d0EroJ1 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Hi, attached patch replaces select() by pselect() in the gpsd main loop. This should make gpsd behaving nice when idle and avoids a race condition when multiple signals arrive shortly one after another. if COMPAT_SELECT is defined, the code should behave exactly as it did before, for systems where pselect() isn't available. COMPAT_SELECT needs a configuration variable. Eckhart --nextPart16583279.x24d0EroJ1 Content-Disposition: attachment; filename="gpsd-pselect.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="gpsd-pselect.patch" diff --git a/gpsd.c b/gpsd.c index d342f5a..5c0e8e1 100644 --- a/gpsd.c +++ b/gpsd.c @@ -9,6 +9,7 @@ #include #include #include /* for select() */ +#include #include #include #include @@ -1765,7 +1766,11 @@ int main(int argc, char *argv[]) int i, option, dfd; int msocks[2] = {-1, -1}; bool go_background = true; +#ifdef COMPAT_SELECT struct timeval tv; +#else + sigset_t emptyset, blockset; +#endif /* COMPAT_SELECT */ const struct gps_type_t **dp; bool in_restart; @@ -2050,6 +2055,14 @@ int main(int argc, char *argv[]) } /* Handle some signals */ +#ifndef COMPAT_SELECT + sigemptyset(&blockset); + sigaddset(&blockset, SIGHUP); + sigaddset(&blockset, SIGINT); + sigaddset(&blockset, SIGTERM); + sigaddset(&blockset, SIGQUIT); + sigprocmask(SIG_BLOCK, &blockset, &emptyset); +#endif /* COMPAT_SELECT */ signalled = 0; (void)signal(SIGHUP, onsig); (void)signal(SIGINT, onsig); @@ -2096,10 +2109,15 @@ int main(int argc, char *argv[]) * low-clock-rate SBCs and the like). */ /*@ -usedef @*/ + errno = 0; + +#ifdef COMPAT_SELECT tv.tv_sec = 1; tv.tv_usec = 0; - errno = 0; if (select(maxfd + 1, &rfds, NULL, NULL, &tv) == -1) { +#else + if (pselect(maxfd + 1, &rfds, NULL, NULL, NULL, &emptyset) == -1) { +#endif if (errno == EINTR) continue; gpsd_report(LOG_ERROR, "select: %s\n", strerror(errno)); --nextPart16583279.x24d0EroJ1-- From MAILER-DAEMON Fri Jan 13 17:24:25 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlpXt-0002yo-6T for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 17:24:25 -0500 Received: from eggs.gnu.org ([140.186.70.92]:36309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlpXp-0002yT-Kw for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 17:24:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlpXo-0001fT-8r for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 17:24:21 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:60798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlpXo-0001fP-02 for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 17:24:20 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 58B02654CD; Fri, 13 Jan 2012 22:24:19 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: gpsd-dev@nongnu.org Date: Fri, 13 Jan 2012 17:24:20 -0500 User-Agent: KMail/1.13.7 (Linux/3.2.0; KDE/4.6.5; x86_64; ; ) References: <3587273.FZPhh6N4pi@obiwan> In-Reply-To: <3587273.FZPhh6N4pi@obiwan> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart8909975.SpJHIfudDq"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201201131724.20860.vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 22:24:23 -0000 --nextPart8909975.SpJHIfudDq Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Friday 13 January 2012 16:06:52 Eckhart W=C3=B6rner wrote: > attached patch replaces select() by pselect() in the gpsd main loop. This > should make gpsd behaving nice when idle and avoids a race condition when > multiple signals arrive shortly one after another. > if COMPAT_SELECT is defined, the code should behave exactly as it did > before, for systems where pselect() isn't available. COMPAT_SELECT needs a > configuration variable. the idle issue doesn't require pselect() to address. you can do that alrea= dy=20 by replacing "tv" with NULL in the select() call. but the current main log= ic=20 seems to imply that this behavior is somewhat desirable (at least when=20 debugging). perhaps the tv argument should be modified that way ? if peop= le=20 are running in debug mode, then poll every second, otherwise wait in=20 definitely. note: i'm certainly not a gpsd expert, so my quick analysis mi= ght=20 be off ... as for the race condition, a little explanation might be in order for peopl= e=20 not versed on esoteric signal behavior. signal() has the property that whe= n=20 the user specified handler is called, the handler is automatically reset to= =20 SIG_DFL. thus there is a race condition from the time someone does `killal= l - HUP gpsd` to the time where gpsd's main loop notices and actually processes= =20 the request. this window cannot be fully closed even if the user signal=20 handler itself calls signal() to setup the handler for future signals. if,= in=20 that window of time where the handler has been reset to SIG_DFL, the user=20 resends with `killall -HUP gpsd`, then the kernel will go ahead and termina= te=20 gpsd. there is no race issue between different signals (e.g. `killall -HUP= =20 gpsd` && `killall -INT gpsd`) since each signal has its own state. but fixing this issue doesn't require pselect() either. simply use sigacti= on()=20 and don't use the SA_RESETHAND flag when registering the handlers. this sh= ould=20 be portable enough for the code to not worry about compat defines. > --- a/gpsd.c > +++ b/gpsd.c >=20 > + sigprocmask(SIG_BLOCK, &blockset, &emptyset); the 3rd arg to sigprocmask() is not an emptyset, it's the old sigset, so th= e=20 variable name needs tweaking. =2Dmike --nextPart8909975.SpJHIfudDq Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPEK8UAAoJEEFjO5/oN/WBHwEQAMBMHtvDrD/oJ+ni08EJp9Eb hGdsLtDVwEwfs52Z3SdhNZzB1Pt74y6XKyA2trJP4q5VEVi6nLAJ3xCfLXJW1wLE VMAiiVeWRlg5eflUGqwMSaUAwhW11xZY9LOODcQsYJ8S3yi+TBWw+dogaIqf3i4A xRzn5NinUBuVXG5c3Ob4CY+gZwBqOdQyLRIUcMtLoqJFwQZxVOuGaEttjIkZc3l/ rxil0USSXgkM8cWmLX1Yh+E38sM/Zz58mDM/kvHCkkm0aGtvlPbHlxfxX+YQSReG yP14Xt3rPBiFa2XHmD++bl+8M1sY4oMU9WXhxrEZLvboIPUrfPLHM84l+YyMcPzJ /ej+KCJ+VakJaxNPV8mPmQjLl6erIbUh1jYLqvxXSR/XnkNjIA5MXKOWdkC3H4b8 TwFfl8ukIkkmX6XHDsnWP3DzJXINdS3ECSGKUTSCUpE29stLNaCYw5KyMhX4XjT0 UyR0PEPFAD7m4r3CB9BbryMtfNbvB4gm8cKaOH3sqsqxgR48dWWsqrx5ZuGGKvzv R+jl5hVxXbnLP+tlWafA2UQPd7Zy2r7LhG2w9/o9YRsXmBC7/t539Mp0Cov1o00I hP1Rl4lns5NihF5WuoRKj+TrfTyiMO7AUbrLPTzovTB0mDyCji/yX0HMbKzJ9oOb A8bp/ms1Gc0XbuzZo2PE =KpwK -----END PGP SIGNATURE----- --nextPart8909975.SpJHIfudDq-- From MAILER-DAEMON Fri Jan 13 17:55:54 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rlq2M-0008NT-BF for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 17:55:54 -0500 Received: from eggs.gnu.org ([140.186.70.92]:47006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlq2J-0008NL-RB for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 17:55:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rlq2I-0006KW-Nc for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 17:55:51 -0500 Received: from moutng.kundenserver.de ([212.227.17.8]:63658) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlq2I-0006KS-Do for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 17:55:50 -0500 Received: from obiwan.localnet (p549BBF2F.dip.t-dialin.net [84.155.191.47]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0M2puc-1SeD4W1Jpe-00sown; Fri, 13 Jan 2012 23:55:38 +0100 From: Eckhart =?ISO-8859-1?Q?W=F6rner?= To: Mike Frysinger Date: Fri, 13 Jan 2012 23:55:37 +0100 Message-ID: <5046892.L2S8KL8bJR@obiwan> User-Agent: KMail/4.8 rc2 (Linux/3.2.0-8-generic; KDE/4.7.97; x86_64; ; ) In-Reply-To: <201201131724.20860.vapier@gentoo.org> References: <3587273.FZPhh6N4pi@obiwan> <201201131724.20860.vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" X-Provags-ID: V02:K0:j5qN53Tg0NxXFYi5cWjklH8vEUB7cLP7qQoq1mp4POQ HKg0MerGDPUrDJSbjwCDclwXWugIGUjOzkxsAdMaiPmHdIRpKI FawCPgRbXOwoHzmKbwZkQOEUmoXF/k5QQIW01xx5Y9Xoo5UTeU soPZqnR2o/Y/nDWYfseDmKJrNn+aJSaYvMYrR1EWhIwdVUe0WN lNJt8ug0PZ/z7b2RO7HiX4RS+Q/VylnbIjSm/usw8G0Hrmlyzq YAMmgNrEfPOKomOSpZM1JQkAfF2VGa+FLGMqfXFxN+K6PZFIOt Oo1xGWD7JiY5SxrJcPTUTC4p6xndUpdPuL12idYAMOIX/mwUOE bJjnPr4ySiOHkZZy+ryQ= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.8 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 22:55:53 -0000 Hi Mike, [I'm subscribed to the ML] Am Freitag, 13. Januar 2012, 17:24:20 schrieb Mike Frysinger: > the idle issue doesn't require pselect() to address. you can do that > already by replacing "tv" with NULL in the select() call. but the current > main logic seems to imply that this behavior is somewhat desirable (at > least when debugging). perhaps the tv argument should be modified that way > ? if people are running in debug mode, then poll every second, otherwise > wait in definitely. note: i'm certainly not a gpsd expert, so my quick > analysis might be off ... I don't see how tv is used in debugging at all. See also the comment before the select(). > as for the race condition, a little explanation might be in order for people > not versed on esoteric signal behavior. signal() has the property that > when the user specified handler is called, the handler is automatically > reset to SIG_DFL. thus there is a race condition from the time someone > does `killall - HUP gpsd` to the time where gpsd's main loop notices and > actually processes the request. this window cannot be fully closed even if > the user signal handler itself calls signal() to setup the handler for > future signals. if, in that window of time where the handler has been > reset to SIG_DFL, the user resends with `killall -HUP gpsd`, then the > kernel will go ahead and terminate gpsd. As you said, the problem is that signal handling using select() is racy. If gpsd is signalled directly before entering the select(), we're stuck in it until something else happens, at which point the signal is indeed processed. You were saying that a second HUP will fix the first HUP if it indeed occurs directly before entering select(). This is true, but not the point. From an outside perspective, a signal has to reliably trigger an action, not only when it is sent twice. > there is no race issue between > different signals (e.g. `killall -HUP gpsd` && `killall -INT gpsd`) since > each signal has its own state. Oh sure, all of the signal handlers write their code to "signalled", which contains the code of the latest signal only. Processing signals therefore only works correctly if we block and only let the signals in one by one, which is exactly what is achieved by the pselect(). > the 3rd arg to sigprocmask() is not an emptyset, it's the old sigset, so the > variable name needs tweaking. The old sigset is the emptyset. Eckhart From MAILER-DAEMON Fri Jan 13 18:20:05 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlqPl-0004B0-45 for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 18:20:05 -0500 Received: from eggs.gnu.org ([140.186.70.92]:39948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqPi-00049A-AV for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:20:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlqPh-0001Y5-2M for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:20:02 -0500 Received: from adsl-71-159-209-148.dsl.pltn13.sbcglobal.net ([71.159.209.148]:45861 helo=radagast.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqPg-0001Xn-Mp for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:20:01 -0500 Received: from [10.100.40.179] (host46.tivo.com [::ffff:204.176.49.46]) (AUTH: PLAIN dplatt, TLS: TLSv1/SSLv3,256bits,AES256-SHA) by radagast.org with esmtp; Fri, 13 Jan 2012 14:39:54 -0800 id 00102979.4F10B2BA.00002A54 Message-ID: <4F10B30D.7090605@radagast.org> Date: Fri, 13 Jan 2012 14:41:17 -0800 From: Dave Platt User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20111110 Iceowl/1.0b1 Icedove/3.0.11 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: gpsd-dev@nongnu.org References: <3587273.FZPhh6N4pi@obiwan> <201201131724.20860.vapier@gentoo.org> In-Reply-To: <201201131724.20860.vapier@gentoo.org> X-Enigmail-Version: 1.0.1 X-Mime-Autoconverted: from 8bit to quoted-printable by courier 0.65.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.159.209.148 Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 23:20:03 -0000 On 01/13/2012 02:24 PM, Mike Frysinger wrote: > On Friday 13 January 2012 16:06:52 Eckhart W=C3=B6rner wrote: >> attached patch replaces select() by pselect() in the gpsd main loop. T= his >> should make gpsd behaving nice when idle and avoids a race condition w= hen >> multiple signals arrive shortly one after another. >> if COMPAT_SELECT is defined, the code should behave exactly as it did >> before, for systems where pselect() isn't available. COMPAT_SELECT nee= ds a >> configuration variable. >=20 > the idle issue doesn't require pselect() to address. you can do that a= lready=20 > by replacing "tv" with NULL in the select() call. but the current main = logic=20 > seems to imply that this behavior is somewhat desirable (at least when=20 > debugging). perhaps the tv argument should be modified that way ? if = people=20 > are running in debug mode, then poll every second, otherwise wait in=20 > definitely. note: i'm certainly not a gpsd expert, so my quick analysi= s might=20 > be off ... >=20 > as for the race condition, a little explanation might be in order for p= eople=20 > not versed on esoteric signal behavior. signal() has the property that = when=20 > the user specified handler is called, the handler is automatically rese= t to=20 > SIG_DFL. thus there is a race condition from the time someone does `ki= llall - > HUP gpsd` to the time where gpsd's main loop notices and actually proce= sses=20 > the request. this window cannot be fully closed even if the user signa= l=20 > handler itself calls signal() to setup the handler for future signals. = if, in=20 > that window of time where the handler has been reset to SIG_DFL, the us= er=20 > resends with `killall -HUP gpsd`, then the kernel will go ahead and ter= minate=20 > gpsd. there is no race issue between different signals (e.g. `killall = -HUP=20 > gpsd` && `killall -INT gpsd`) since each signal has its own state. >=20 > but fixing this issue doesn't require pselect() either. simply use sig= action()=20 > and don't use the SA_RESETHAND flag when registering the handlers. thi= s should=20 > be portable enough for the code to not worry about compat defines. There's another tricky select/pselect race condition issue... near and de= ar to my heart, as it caused me no end of heartburn recently. The problem is this: if you want to select() on a bunch of descriptors, and also have some signal handlers installed, and you want to be sure that you'll wake up from the select() call *either* if one of those signa= ls fires *or* if I/O is possible according to the select()... well, you can'= t do this reliably. The reason: if you want to be awakened from the select() by a signal, yo= u have to make sure that this signal cannot fire prior to the select() star= ting. The only way you can do this is to mask off the signal at other times, an= d un-mask it just before starting the select(). However, the moment you call one of the functions to change your process'= s signal mask (so that the previously-masked-off signals can fire), you open the window... and if one of these signals is already pending, it wil= l fire *immediately*... your signal handler will catch it, do whatever work needs to be done, return, and your code will fall into the signal()... an= d go to sleep, possibly for a very long amount of time. The signal won't result in the select() call exiting immediately (or quickly) because it h= as already fired and been handled. So, if you've got a simple signal handler which simply records the fact t= hat something needs to be done (e.g. sets a flag), and you expect to handle the flag upon coming out of the select() call... then you may end up waiting a *long* time. Possibly your process will hang (e.g. if your select doesn't have a timeout). pselect() was created to close this timing window... it unmasks signals and starts the select() in an atomic fashion. If it unmasks a signal which is already pending, the signal is allowed to fire and then pselect() exits immediately - so, no race condition. Hence, in many places where you want to wake up on a signal *or* on an "I/O is ready", and don't want to use an indefinite timeout, using pselect() is the right way to do this. [This particular problem bit me badly when I was debugging software which was running on an old embedded Linux kernel, which did not implement pselect() in the kernel. Instead, glibc has a "convenience implementation" of pselect() - which simply changes the signal mask and calls select(). In other words, the glibc code re-introduces the very timing race condition that pselect() was intended to cure... and it resulted in our system hanging at boot in an unpredictable fashion.] Although I haven't looked at that particular bit of gpsd code, I'd bet that the select() call has a timeout *precisely* to work around this select() race condition. Changing to pselect() would be a fix rather than a workaround... and by eliminating the need for the timeout it could reduce overhead slightly by eliminating unneeded wakeups. From MAILER-DAEMON Fri Jan 13 18:32:59 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlqcF-000618-Qt for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 18:32:59 -0500 Received: from eggs.gnu.org ([140.186.70.92]:43454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqcC-00060x-Uy for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:32:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlqcC-0003HA-3U for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:32:56 -0500 Received: from moutng.kundenserver.de ([212.227.126.171]:54136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqcB-0003Gy-QQ for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:32:56 -0500 Received: from obiwan.localnet ([82.113.119.164]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MFwt0-1Rrq5a42Hm-00FJFS; Sat, 14 Jan 2012 00:32:53 +0100 From: Eckhart =?ISO-8859-1?Q?W=F6rner?= To: gpsd-dev@nongnu.org Date: Sat, 14 Jan 2012 00:32:48 +0100 Message-ID: <1419755.JazILDx31y@obiwan> User-Agent: KMail/4.8 rc2 (Linux/3.2.0-8-generic; KDE/4.7.97; x86_64; ; ) In-Reply-To: <4F10B30D.7090605@radagast.org> References: <3587273.FZPhh6N4pi@obiwan> <201201131724.20860.vapier@gentoo.org> <4F10B30D.7090605@radagast.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" X-Provags-ID: V02:K0:RUAO/d3KmeA/t3kkxwlXNVjx64EgBUaZL1AqZ/oQFYd shapwS76wByiFkIVUsoeme0t/Ex0DcAr0sFlDXdIq0iYTjFPTk 1XyAulAJL/CW+/4rDcOD4KR/b9nJDMY7dzBYGsTv4BJt4Gdhbi KdhMEDOOG8Oz1Q/vOu0e23TknQjSuJ/75MSrYw+UUpMRVN5mTa 0OBbec90gqflUvXcs5FBVGambKfwXHPu9w3yIkPCo6xKQTjcjR Lj08MO2q6Z1+eF1+/hO+EyhXqWcq1bYo6RSUscLwSqPU6JhR1L Q0OhdJ/L54gSF4vA6UnbJsLtOnWu7HSLhKIMUpa9lVt5zT7FxQ sqzRHx7VnoKKIepokxE4= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.126.171 Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 23:32:58 -0000 Hi Dave, a race condition lead to us giving more or less the same answer. ;-) Am Freitag, 13. Januar 2012, 14:41:17 schrieb Dave Platt: > [This particular problem bit me badly when I was debugging software > which was running on an old embedded Linux kernel, which did not > implement pselect() in the kernel. Instead, glibc has a "convenience > implementation" of pselect() - which simply changes the signal mask > and calls select(). In other words, the glibc code re-introduces > the very timing race condition that pselect() was intended to cure... > and it resulted in our system hanging at boot in an unpredictable > fashion.] Thanks for explaining this; this is exactly the reason why there is compatibility code that still uses select() with a timeout. Using the userspace implemention of pselect() probably leads to worse results (hangs) than the existing code. Eckhart From MAILER-DAEMON Fri Jan 13 18:36:02 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlqfB-0006qx-W7 for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 18:36:01 -0500 Received: from eggs.gnu.org ([140.186.70.92]:33571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlqf7-0006lX-RN for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:35:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rlqf6-0003uk-9s for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:35:57 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:36638) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlqf6-0003uZ-0W for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:35:56 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id B84EF1B400B; Fri, 13 Jan 2012 23:35:54 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: Eckhart =?iso-8859-1?q?W=F6rner?= Date: Fri, 13 Jan 2012 18:35:55 -0500 User-Agent: KMail/1.13.7 (Linux/3.2.0; KDE/4.6.5; x86_64; ; ) References: <3587273.FZPhh6N4pi@obiwan> <201201131724.20860.vapier@gentoo.org> <5046892.L2S8KL8bJR@obiwan> In-Reply-To: <5046892.L2S8KL8bJR@obiwan> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2401735.aALMR73JJR"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201201131835.56597.vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 23:35:59 -0000 --nextPart2401735.aALMR73JJR Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Friday 13 January 2012 17:55:37 Eckhart W=C3=B6rner wrote: > Am Freitag, 13. Januar 2012, 17:24:20 schrieb Mike Frysinger: > > the idle issue doesn't require pselect() to address. you can do that > > already by replacing "tv" with NULL in the select() call. but the > > current main logic seems to imply that this behavior is somewhat > > desirable (at least when debugging). perhaps the tv argument should be > > modified that way ? if people are running in debug mode, then poll > > every second, otherwise wait in definitely. note: i'm certainly not a > > gpsd expert, so my quick analysis might be off ... >=20 > I don't see how tv is used in debugging at all. See also the comment befo= re > the select(). true ... i misread the select() loop incorrectly. in this case, tv is used= to=20 mitigate the race condition you highlight below ... > > as for the race condition, a little explanation might be in order for > > people not versed on esoteric signal behavior. signal() has the > > property that when the user specified handler is called, the handler is > > automatically reset to SIG_DFL. thus there is a race condition from the > > time someone does `killall - HUP gpsd` to the time where gpsd's main > > loop notices and actually processes the request. this window cannot be > > fully closed even if the user signal handler itself calls signal() to > > setup the handler for future signals. if, in that window of time where > > the handler has been reset to SIG_DFL, the user resends with `killall > > -HUP gpsd`, then the kernel will go ahead and terminate gpsd. >=20 > As you said, the problem is that signal handling using select() is racy. = If > gpsd is signalled directly before entering the select(), we're stuck in it > until something else happens, at which point the signal is indeed > processed. true ... that race your pselect() change fixes -- if the signal comes in af= ter=20 the "while (0 =3D=3D signalled)" check and before the select() syscall, the= =20 response to the signal is delayed by 1 second (the timeout specified by tv). > You were saying that a second HUP will fix the first HUP if it indeed > occurs directly before entering select(). This is true, but not the point. it's worse than that. you cannot send any signal a 2nd time once the first= has=20 been delivered. the relationship to where the checking occurs doesn't matt= er. =20 at any point before the app exits, sending the same signal a 2nd time will= =20 cause the kernel to immediately terminate it. your original changelog is too vague to figure out which race and which sig= nals=20 you're referring to. i'd suggest reposting with clarification and real det= ails=20 as to what it is fixing. > From an outside perspective, a signal has to reliably trigger an action, > not only when it is sent twice. of course > > the 3rd arg to sigprocmask() is not an emptyset, it's the old sigset, so > > the variable name needs tweaking. >=20 > The old sigset is the emptyset. there is no guarantee this is true. signal masks are inherited across fork= s=20 and execs. =2Dmike --nextPart2401735.aALMR73JJR Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPEL/cAAoJEEFjO5/oN/WB4vAQAI994/oray3nwdXDfyAtMSSC N+ExsqRIwbB9YvXjDJQ/8/A0G6YyTiCRgEwy+oYBvnMksAJJffcMXY3qCtzRsjpV N1DUfiOUn+aEtT4tnkxfx63j1Ll/8cyocDQBl0XuZ1rzqn+3POkkuDrX5FpaYxEW mDf/AXLsiwWLWkjmKkAMGSIIBL7YIK/l7C5RdjwyDPP7/rqKirqIfq/fc7PU/DW6 XGtrf5DyJYudwYtNrN/+UkCgjvX3x7r57Z4AUiOG2t2pqN8ATaNY6sTqQL78tGgh Q55SY0qzOD0tCVP1S/qTBuA9y8xfzU9/fwRjSW7AMcYHVgRNUXhS7de/tk2gp+ZK XNB+hQBXzC2uUE2NjEOsx75A7gyGyPjqyEa7MBj+fiNgGPT+xRqMU+cxPLlrRoQS AarGxBnRBMSde+/35FApA6N2y/oWz3nNZGAWSfnFnto+0qLhh8SMRXySr+B/aD3n V/q7+9yzprdN9iSwUD7ksnRLZmJrBwQges/L7JhOvQzpcGdZybPulgcybVU3Uh/c wX/FcZez5R01OXWVehoUTYQgSkXufFLlrv6B/nALPU3VEmi8S8c2GE4nGEFUGEEj yoP9tNz5EBiISIDnuoME39B0aw+Eyb8Rm7hXLjkfIuY99Qvq0ClfBipJhYggSXo8 fs4k8j8kceL6YG7s1xoz =iqD4 -----END PGP SIGNATURE----- --nextPart2401735.aALMR73JJR-- From MAILER-DAEMON Fri Jan 13 18:39:26 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlqiU-0000o6-3j for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 18:39:26 -0500 Received: from eggs.gnu.org ([140.186.70.92]:48639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqiS-0000o0-0b for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:39:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlqiR-0004Ur-3L for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:39:23 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:36886) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqiQ-0004Uc-VA for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:39:23 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 3CC721B400B; Fri, 13 Jan 2012 23:39:22 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: gpsd-dev@nongnu.org Date: Fri, 13 Jan 2012 18:39:23 -0500 User-Agent: KMail/1.13.7 (Linux/3.2.0; KDE/4.6.5; x86_64; ; ) References: <3587273.FZPhh6N4pi@obiwan> <201201131724.20860.vapier@gentoo.org> <4F10B30D.7090605@radagast.org> In-Reply-To: <4F10B30D.7090605@radagast.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2005072.x2DfghGvRY"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201201131839.24156.vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 23:39:25 -0000 --nextPart2005072.x2DfghGvRY Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Friday 13 January 2012 17:41:17 Dave Platt wrote: > [This particular problem bit me badly when I was debugging software > which was running on an old embedded Linux kernel, which did not > implement pselect() in the kernel. Instead, glibc has a "convenience > implementation" of pselect() - which simply changes the signal mask > and calls select(). In other words, the glibc code re-introduces > the very timing race condition that pselect() was intended to cure... > and it resulted in our system hanging at boot in an unpredictable > fashion.] glibc has to provide a POSIX API to the apps compiled against it. if the=20 kernel glibc is running on cannot provide the corresponding functionality, = it=20 often has fallback logic to emulate it as best it can. in this case,=20 pselect() cannot be implemented completely in userspace ... it requires ker= nel=20 support to be bulletproof. i'm not sure what else you can reasonably expect glibc to do ... certainly= =20 calling abort() is worse imo. =2Dmike --nextPart2005072.x2DfghGvRY Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPEMCsAAoJEEFjO5/oN/WBwrgQAIuEtBMoEQN6/sqgVLFqszqy 5BPHxo4bPzHq+Uw3+29hbJ7cmqsAydtab1CD4v0V2p+VW5mS6ow+kBaDBPxuMH+g Mj6Rn6zL55rR9Pz7SBDOagYEKq7LFWMLHwrq52bTmCYDiqyBFl75rNtdtxnFqkwi COBEZRizZGQpixarmH4Ga69B5GaWzP1zOhzyHfgDevi9j/vhqsK0giuTWfdi655B f8fg2WXMlA3+AjgCBjI6TaHHBGaja1WyOGU3JtYe+qv1GpZOfYuw7E4rsO2fH9Ds 79eeVNws4w3LEwoFrbOWtmZifeT6kLExvu103ztwY1/rtiGWmh8SrReTRKBQXXHK BuUN1HsL8GUv4/MGGRzM9Rq8ZF3rEs2JW27MIM94gPtZF/o6n6A8b+qiqjg7Cpnm XN80+ZmG9pGvUw5CR84B3YHdxM5W9xV70ifBjdUnvYkGtlOlKtrgrmFqNDKioxtA tG4BROd2R3VYuWpwKEV1d5roxN169s8r5NrUk4OqEr2l6YyDJ3sF0Ivmb/tbvwkn PaxrLUb8m+XumMGT98Gj0uwY+BsNUOFN9AP2oTyMNJUHPviweOCv9IgqFHOLcXoe ERcCnzvrhtUPM/sU6bV5CAgBiFontF9dCTcfctP91s2R05Idz6bXaUUIgp1pMPuO 8vsbqr+rLaBh5NRemw7m =fXWm -----END PGP SIGNATURE----- --nextPart2005072.x2DfghGvRY-- From MAILER-DAEMON Fri Jan 13 18:52:45 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlqvN-0002QM-BW for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 18:52:45 -0500 Received: from eggs.gnu.org ([140.186.70.92]:49254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqvL-0002PX-F8 for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:52:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlqvK-0006Gq-BT for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:52:43 -0500 Received: from adsl-71-159-209-148.dsl.pltn13.sbcglobal.net ([71.159.209.148]:58412 helo=radagast.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqvK-0006GK-30 for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 18:52:42 -0500 Received: from [10.100.40.179] (host46.tivo.com [::ffff:204.176.49.46]) (AUTH: PLAIN dplatt, TLS: TLSv1/SSLv3,256bits,AES256-SHA) by radagast.org with esmtp; Fri, 13 Jan 2012 15:52:38 -0800 id 00102854.4F10C3C6.000032BC Message-ID: <4F10C41B.7030907@radagast.org> Date: Fri, 13 Jan 2012 15:54:03 -0800 From: Dave Platt User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20111110 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 To: Mike Frysinger References: <3587273.FZPhh6N4pi@obiwan> <201201131724.20860.vapier@gentoo.org> <4F10B30D.7090605@radagast.org> <201201131839.24156.vapier@gentoo.org> In-Reply-To: <201201131839.24156.vapier@gentoo.org> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.159.209.148 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2012 23:52:44 -0000 > glibc has to provide a POSIX API to the apps compiled against it. if the > kernel glibc is running on cannot provide the corresponding functionality, it > often has fallback logic to emulate it as best it can. in this case, > pselect() cannot be implemented completely in userspace ... it requires kernel > support to be bulletproof. > > i'm not sure what else you can reasonably expect glibc to do ... certainly > calling abort() is worse imo. Well... the problem is that in this case, it's providing a "POSIX API" emulation which doesn't actually implement the API's functionality according to spec (and, as you point out, it cannot). Worse, it does so "silently" - the program appears to run, but the one critical characteristic for which pselect() was designed, is the very one not provided, and this can lead to delayed and unpredictable failures. I appreciate the desire to be "API compliant", but in this case the "convenience" provided by glibc is a bit like the old prayer... "May God protect me from my friends - my enemies, I can handle!" Personally I'd prefer to either not implement the function at all (and acknowledge that on this particular system, glibc is unable to be fully POSIX-compliant), or print a short warning the first time pselect() is called on such a system. Or, maybe, move the pselect() stub into a separate library which must be explicitly linked in rather than auto-fetched, so that it's more apparent that the programmer is explicitly accepting the use of a noncompliant emulation. From MAILER-DAEMON Fri Jan 13 19:18:49 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlrKb-0005Hq-RH for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 19:18:49 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlrKa-0005Hk-6b for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 19:18:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlrKZ-0000yI-42 for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 19:18:48 -0500 Received: from moutng.kundenserver.de ([212.227.126.187]:52523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlrKY-0000y8-Of for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 19:18:47 -0500 Received: from obiwan.localnet (agsb-5d85160b.pool.mediaWays.net [93.133.22.11]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0Lr6Jj-1SHMX80w6t-00eFUS; Sat, 14 Jan 2012 01:18:45 +0100 From: Eckhart =?ISO-8859-1?Q?W=F6rner?= To: gpsd-dev@nongnu.org Date: Sat, 14 Jan 2012 01:18:44 +0100 Message-ID: <8453308.R6inVsYVT7@obiwan> User-Agent: KMail/4.8 rc2 (Linux/3.2.0-8-generic; KDE/4.7.97; x86_64; ; ) In-Reply-To: <201201131835.56597.vapier@gentoo.org> References: <3587273.FZPhh6N4pi@obiwan> <5046892.L2S8KL8bJR@obiwan> <201201131835.56597.vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" X-Provags-ID: V02:K0:rZ1diIRnBuUGnmSYxXIQdLg7yKSir9xhibgJzy/DPhV mrwzMkBEcSToa7gQozB/D7jl9C47NoCC1XdxtHEAHYx2ejDprl ZyA0N3Wo2sfAXEhnclw4NPuCBgbFx1/eyy00JHl8eQzJkV1LBG /uY+GvPEr4ZVP512hjtpio3A11xVjmQoo8y1R44XY7LkTgstjb LyZ2N9NGxrizSvUfOPZHndUmofcEb/jelrlE1gcvj1o7rbXmKk ZV/34I1kqjxKp7bkW75sImQ6xfRnNOZLGhMBuM1vpViLvm9rSk 3tTJkYIvWnMKtSG32QGc+aIWStj2mL5i47gSz605sGxJI66ww= = X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.126.187 Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 00:18:48 -0000 Hi Mike, Am Freitag, 13. Januar 2012, 18:35:55 schrieben Sie: > it's worse than that. you cannot send any signal a 2nd time once the first > has been delivered. the relationship to where the checking occurs doesn't > matter. at any point before the app exits, sending the same signal a 2nd > time will cause the kernel to immediately terminate it. That I don't understand. The onsig handler can run twice in rapid succession, can't it? > your original changelog is too vague to figure out which race and which > signals you're referring to. i'd suggest reposting with clarification and > real details as to what it is fixing. Well, the patch originated from a discussion on irc, it was only reposted on the mailing list for eternity. I guess the discussion documents the exact reasons for the patch already. > > > the 3rd arg to sigprocmask() is not an emptyset, it's the old sigset, so > > > the variable name needs tweaking. > > > > The old sigset is the emptyset. > > there is no guarantee this is true. signal masks are inherited across forks > and execs. You're right, I forgot forks/execs. (Although it seems as if at the time of writing the patch, my subconscious made sure this case was handled properly.) Eckhart From MAILER-DAEMON Fri Jan 13 22:29:43 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RluJL-0000jE-Te for mharc-gpsd-dev@gnu.org; Fri, 13 Jan 2012 22:29:43 -0500 Received: from eggs.gnu.org ([140.186.70.92]:47323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RluJJ-0000iG-7G for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 22:29:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RluJI-0005Je-5z for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 22:29:41 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:44654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RluJH-0005Ja-RM for gpsd-dev@nongnu.org; Fri, 13 Jan 2012 22:29:40 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id E736A1B4003 for ; Sat, 14 Jan 2012 03:29:37 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: gpsd-dev@nongnu.org Date: Fri, 13 Jan 2012 22:29:40 -0500 User-Agent: KMail/1.13.7 (Linux/3.2.0; KDE/4.6.5; x86_64; ; ) References: <3587273.FZPhh6N4pi@obiwan> <201201131835.56597.vapier@gentoo.org> <8453308.R6inVsYVT7@obiwan> In-Reply-To: <8453308.R6inVsYVT7@obiwan> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1844608.zeVLjfntae"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201201132229.40903.vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 03:29:42 -0000 --nextPart1844608.zeVLjfntae Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Friday 13 January 2012 19:18:44 Eckhart W=C3=B6rner wrote: > Am Freitag, 13. Januar 2012, 18:35:55 schrieben Sie: > > it's worse than that. you cannot send any signal a 2nd time once the > > first has been delivered. the relationship to where the checking occurs > > doesn't matter. at any point before the app exits, sending the same > > signal a 2nd time will cause the kernel to immediately terminate it. >=20 > That I don't understand. The onsig handler can run twice in rapid > succession, can't it? it can if gpsd is sent diff signals. but the way signal() works is that th= e=20 handler for that signal is reset to SIG_DFL before the user handler is call= ed. =20 this is one reason why sigaction() was introduced. at a high level, you can think of it as: - gpsd calls signal(SIGHUP, onsig) - gpsd calls select(), gets some data, and starts to process it (most of code in while() loop after the select()) - user runs `killall -HUP gpsd` - kernel looks up the handler for gpsd for SIGHUP and gets "onsig" - kernel sets the handler for gpsd for SIGHUP to SIG_DFL - kernel forces gpsd to run onsig (details here don't matter) - gpsd runs onsig and returns - kernel restores gpsd to wherever it was before - gpsd continues executing (hasn't gotten to top of while() loop where "signalled" is checked) - user runs `killall -HUP gpsd` - kernel looks up the handler for gpsd for SIGHUP and gets SIG_DFL - kernel terminates process immediately gpsd doesn't get a chance to finish cleaning up after itself :( i think your pselect() change indirectly fixes this because it blocks all=20 signals and only allows one to get through at a time. then gpsd either exi= ts,=20 or it restarts and resets all the signal handlers via the longjmp(). along these lines, i'm not sure your sigprocmask() call is at the right pla= ce. =20 consider the code path: - setjmp() - sigprocmask(&newsigset, &oldsigset) - pselect() - SIGHUP is handled - longjmp() - sigprocmask(&newsigset, &oldsigset) so the 2nd call to sigprocmask() will end up saving your newsigset into the= =20 old one. in practice, it won't make a difference to the current code base,= but=20 it sounds pretty fragile. so all in all, this should probably be cleanly fixed by changing the signal= ()=20 calls to sigaction() and then moving all the signal init stuff (including y= our=20 sigprocmask()) to before the setjmp() call. > > your original changelog is too vague to figure out which race and which > > signals you're referring to. i'd suggest reposting with clarification > > and real details as to what it is fixing. >=20 > Well, the patch originated from a discussion on irc, it was only reposted > on the mailing list for eternity. > I guess the discussion documents the exact reasons for the patch already. keeping it all in one place (git log) makes it a lot easier to recover than= =20 trying to correlate mailing lists and commits based on dates =2Dmike --nextPart1844608.zeVLjfntae Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPEPakAAoJEEFjO5/oN/WBlAYP/j3cwBX/TB+mifH9XNRtaW1S KyiEyetYFh4RqiZlbSvypzY15hHa6vnIgvAIDRRSmbjRBXgf43Wjzsgx8E4tg14B 81W3D4kXjw8Eb3o/OIf+TAtbdlnTEetlyLTjFXYE+c7QwQwYa3PHk9L0Z43xHVFv hOykcyF0N4rmwRPmFh/RfXw+lkJW2l1m7XeJuiI9laVR2z+aBI0Yt7R+ELXzP3X8 Ef6Q1ta3TEe/wat4UL08uUbhp+DXMq/ogSJ0Age6DqVFTC8gyFAL2NS6iiUSv3c+ /M43R7+yjUXBdHPHrMjovQC4QGwudvJEkExuCSOU7UsCuLcV7LbJlSVTlX8eRn8B juq87TlARf8GdG8UiM5x5e5r05UjGTQjCYy1lahi0W6kiUuc4bWPx51Jjrw70nKj 2vHjID2QnxtcijB2AwFI8bFTbpWyXU7ohTNXHYj9mWfBeRuj5r/HLrnLOqNDHoev zAJTfjKuFng+2X/IdIeqVnGwozsmREuDtukL71ttU6ldEwr9vNjHrJidw++4s+Y9 nU8XAbCZ53by2C7SuIgW1Uhwrb4id3Pptobuz1zK/TldeeVKuLiF6jHtlRL4vxVM vIQvjotg9EIF2DbiWgGMENtBHFRhMsCXLdayHTK+IooNPQYecx8LcnXoEV7GAATb XYQcgsx6dFTKNdUL4WTH =ZrHF -----END PGP SIGNATURE----- --nextPart1844608.zeVLjfntae-- From MAILER-DAEMON Sat Jan 14 01:10:11 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rlwod-0002qa-Gt for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 01:10:11 -0500 Received: from eggs.gnu.org ([140.186.70.92]:47201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlwoX-0002i8-J9 for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 01:10:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlwoW-0006S7-0N for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 01:10:05 -0500 Received: from liara-nlb.chalmers.se ([129.16.10.241]:47808 helo=liara.ita.chalmers.se) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlwoV-0006R7-Kh for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 01:10:03 -0500 Received: from shuttle1.fy.chalmers.se (129.16.110.71) by smtp.chalmers.se (129.16.10.240) with Microsoft SMTP Server (TLS) id 14.1.355.2; Sat, 14 Jan 2012 06:43:16 +0100 Date: Sat, 14 Jan 2012 06:43:08 +0100 From: =?ISO-8859-15?Q?H=E5kan_Johansson?= X-X-Sender: htj@shuttle1.fy.chalmers.se To: In-Reply-To: <201201132229.40903.vapier@gentoo.org> Message-ID: References: <3587273.FZPhh6N4pi@obiwan> <201201131835.56597.vapier@gentoo.org> <8453308.R6inVsYVT7@obiwan> <201201132229.40903.vapier@gentoo.org> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="276907886-1039027877-1326519796=:24065" X-Originating-IP: [129.16.110.71] X-detected-operating-system: by eggs.gnu.org: Windows XP/2000 (RFC1323+, w+, tstamp-) X-Received-From: 129.16.10.241 Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 06:10:06 -0000 --276907886-1039027877-1326519796=:24065 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8BIT Regarding (p)select and signal races, I did not see the 'self-pipe trick' mentioned in the discussion. Quoting http://www.kernel.org/doc/man-pages/online/pages/man2/select.2.html: "On systems that lack pselect(), reliable (and more portable) signal trapping can be achieved using the self-pipe trick (where a signal handler writes a byte to a pipe whose other end is monitored by select() in the main program.)" This fixed a similar problem for me once. There was no select, just reads, but the race was locking a data acquisition system up when bad luck struck. Cheers, Håkan --276907886-1039027877-1326519796=:24065-- From MAILER-DAEMON Sat Jan 14 01:25:49 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rlx3l-00043i-4P for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 01:25:49 -0500 Received: from eggs.gnu.org ([140.186.70.92]:49757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlx3g-00040K-IW for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 01:25:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rlx3f-0008Gr-Fg for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 01:25:44 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:49619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlx3f-0008Gk-7I for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 01:25:43 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 884F21B4003 for ; Sat, 14 Jan 2012 06:25:41 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: gpsd-dev@nongnu.org Date: Sat, 14 Jan 2012 01:25:45 -0500 User-Agent: KMail/1.13.7 (Linux/3.2.0; KDE/4.6.5; x86_64; ; ) References: <3587273.FZPhh6N4pi@obiwan> <201201132229.40903.vapier@gentoo.org> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3331952.j5j7IWPKPA"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201201140125.45555.vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 06:25:45 -0000 --nextPart3331952.j5j7IWPKPA Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Saturday 14 January 2012 00:43:08 H=C3=A5kan Johansson wrote: > Regarding (p)select and signal races, I did not see the 'self-pipe trick' > mentioned in the discussion. Quoting > http://www.kernel.org/doc/man-pages/online/pages/man2/select.2.html: >=20 > "On systems that lack pselect(), reliable (and more portable) signal > trapping can be achieved using the self-pipe trick (where a signal handler > writes a byte to a pipe whose other end is monitored by select() in the > main program.)" neat trick, but i wonder if we even have to bother. pselect() has been in = the=20 Linux kernel (and thus race free) for almost 6 years. the select() based=20 code, while admittedly racy, isn't that big of a deal -- at worse, the code= =20 takes 1 second to respond. i think this is an acceptable trade off -- inst= all=20 a kernel from the last 6 years, or suck it up ;). =2Dmike --nextPart3331952.j5j7IWPKPA Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPER/pAAoJEEFjO5/oN/WBQowQALo5zPlURJJfFIT2p2qyvfmc ikNjAkVa0h0+iRAZ/Yu9qe2/EUyKqsKCCjsyuAx5atIymumcuKO4BwcUJVMbmMqo 3TYKav9hXMZCzoMQ1yv6Co4223uwPKplB8GzPD+bbbItRRpWJ+fSdMyTRPz/Wp/4 dPxxUDiOh1l6n5BcndgxHKyT80tLhYEl0GOLb7OqeEsdpxPulo7lrT/ZHdOQ6Kei FGeIPa8BpVZlt2OaJcZm3wqK0wn0WedkEipBFl6+4Y9TfYGn/ray+XfdNPje75tz aUqBkBrY55INt/S4hahhFkl6wmLPTug9EWSHaasFf/6FmjgJQIV4My9nkosUGhiZ xF+ld4lsnwdDn9xEGrz6LPfs3LKi4RbghejDur2XY0h9ghvjIWCm4lB6ad6yWdrF +wY5qbQoJcMZer/I/Wl/QysRiEhxWzk7RDyO64AdcGdNL7rxiREWkUlhrjijFnXR lKkQ3+IjlNkfuOoGHHk9hQMhGPXxoHDQQb8SdL3tQxKF2Cm+j6IZTvtg23iCpytr ycndbqmXw7D/lCXjpLOhzXa0BehVQUGlh4HxQXvBvQCVtE6lrZc6sCfGUZequ/aE 2KOpt0bC10zTtl6S/rJ7WNZMxh7pW2A3EVdFAIE1AeIUmhF7WHmfi3jwHtZY9k76 FADsEwM+fI7m233NgZbz =fZjF -----END PGP SIGNATURE----- --nextPart3331952.j5j7IWPKPA-- From MAILER-DAEMON Sat Jan 14 02:01:15 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rlxc3-0006OZ-C8 for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 02:01:15 -0500 Received: from eggs.gnu.org ([140.186.70.92]:47410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlxc0-0006M1-5S for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 02:01:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rlxbx-0004ZL-TI for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 02:01:12 -0500 Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5]:52564 helo=snark.thyrsus.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rlxbx-0004Z7-Qs for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 02:01:09 -0500 Received: by snark.thyrsus.com (Postfix, from userid 1000) id 5E00242A47; Sat, 14 Jan 2012 02:00:59 -0500 (EST) Date: Sat, 14 Jan 2012 02:00:58 -0500 From: "Eric S. Raymond" To: Mike Frysinger Message-ID: <20120114070058.GA9044@thyrsus.com> References: <3587273.FZPhh6N4pi@obiwan> <201201131835.56597.vapier@gentoo.org> <8453308.R6inVsYVT7@obiwan> <201201132229.40903.vapier@gentoo.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gKMricLos+KVdGMg" Content-Disposition: inline In-Reply-To: <201201132229.40903.vapier@gentoo.org> Organization: Eric Conspiracy Secret Labs X-Eric-Conspiracy: There is no conspiracy User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.162.243.5 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: esr@thyrsus.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 07:01:13 -0000 --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Mike Frysinger : > so all in all, this should probably be cleanly fixed by changing the > signal() calls to sigaction() and then moving all the signal init > stuff (including your sigprocmask()) to before the setjmp() call. *That* sounds like a good change reagardless - I'd take that patch. --=20 Eric S. Raymond --gKMricLos+KVdGMg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iD8DBQFPESgprfUW04Qh8RwRApt1AJ4jSI/xofz6m9x5C9jieYVNDGZBywCg1PMt QBqdE87xRUxvs+H2FjX2R3Y= =rdrz -----END PGP SIGNATURE----- --gKMricLos+KVdGMg-- From MAILER-DAEMON Sat Jan 14 02:03:51 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RlxeZ-0006ez-1t for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 02:03:51 -0500 Received: from eggs.gnu.org ([140.186.70.92]:47708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlxeW-0006dL-LW for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 02:03:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlxeV-0004mk-Gs for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 02:03:48 -0500 Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5]:52584 helo=snark.thyrsus.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlxeV-0004mg-EO for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 02:03:47 -0500 Received: by snark.thyrsus.com (Postfix, from userid 1000) id CD9E442A48; Sat, 14 Jan 2012 02:03:38 -0500 (EST) Date: Sat, 14 Jan 2012 02:03:38 -0500 From: "Eric S. Raymond" To: Mike Frysinger Message-ID: <20120114070338.GB9044@thyrsus.com> References: <3587273.FZPhh6N4pi@obiwan> <201201132229.40903.vapier@gentoo.org> <201201140125.45555.vapier@gentoo.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1LKvkjL3sHcu1TtY" Content-Disposition: inline In-Reply-To: <201201140125.45555.vapier@gentoo.org> Organization: Eric Conspiracy Secret Labs X-Eric-Conspiracy: There is no conspiracy User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.162.243.5 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: esr@thyrsus.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 07:03:49 -0000 --1LKvkjL3sHcu1TtY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Mike Frysinger : > neat trick, but i wonder if we even have to bother. pselect() has been i= n the=20 > Linux kernel (and thus race free) for almost 6 years. the select() based= =20 > code, while admittedly racy, isn't that big of a deal -- at worse, the co= de=20 > takes 1 second to respond. i think this is an acceptable trade off -- in= stall=20 > a kernel from the last 6 years, or suck it up ;). I concur. It's a tiny race window, the consequences aren't horrible, and given those circumstances I'd rather keep our code complexity down than pull fancy tricks like the self-pipe hack. --=20 Eric S. Raymond --1LKvkjL3sHcu1TtY Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iD8DBQFPESjKrfUW04Qh8RwRAknlAKD5AJrNHfrzh/1ezUdDH0UiYFWVBgCff1s2 LOXBwU04yrFKxWA3dQ0SpDk= =/5i+ -----END PGP SIGNATURE----- --1LKvkjL3sHcu1TtY-- From MAILER-DAEMON Sat Jan 14 06:19:54 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rm1eM-0007DT-CO for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 06:19:54 -0500 Received: from eggs.gnu.org ([140.186.70.92]:57961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm1eJ-0007BB-Qg for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 06:19:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm1eI-0002iq-GB for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 06:19:51 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:60370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm1eI-0002ij-AX for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 06:19:50 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 5BDDA1B4004 for ; Sat, 14 Jan 2012 11:19:48 +0000 (UTC) From: Mike Frysinger To: gpsd-dev@nongnu.org Date: Sat, 14 Jan 2012 06:19:53 -0500 Message-Id: <1326539993-15588-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.8.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Subject: [gpsd-dev] [PATCH] gpsd: use sigaction() to register signals X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 11:19:52 -0000 We want to avoid the unportable signal() semantics wrt handlers being reset upon signal delivery. Signed-off-by: Mike Frysinger --- note: only lightly tested with `./gpsd -N` and running `kill` gpsd.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gpsd.c b/gpsd.c index d342f5a..2a0855c 100644 --- a/gpsd.c +++ b/gpsd.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #ifndef S_SPLINT_S #include @@ -1768,6 +1769,7 @@ int main(int argc, char *argv[]) struct timeval tv; const struct gps_type_t **dp; bool in_restart; + struct sigaction sa; #ifdef PPS_ENABLE /*@-nullpass@*/ @@ -2038,6 +2040,16 @@ int main(int argc, char *argv[]) subscribers[i].fd = UNALLOCATED_FD; #endif /* SOCKET_EXPORT_ENABLE*/ + /* Handle some signals */ + sa.sa_flags = 0; + sa.sa_handler = onsig; + sigfillset(&sa.sa_mask); + (void)sigaction(SIGHUP, &sa, NULL); + (void)sigaction(SIGINT, &sa, NULL); + (void)sigaction(SIGTERM, &sa, NULL); + (void)sigaction(SIGQUIT, &sa, NULL); + (void)signal(SIGPIPE, SIG_IGN); + /* daemon got termination or interrupt signal */ if (setjmp(restartbuf) > 0) { /* try to undo all device configurations */ @@ -2049,13 +2061,7 @@ int main(int argc, char *argv[]) gpsd_report(LOG_WARN, "gpsd restarted by SIGHUP\n"); } - /* Handle some signals */ signalled = 0; - (void)signal(SIGHUP, onsig); - (void)signal(SIGINT, onsig); - (void)signal(SIGTERM, onsig); - (void)signal(SIGQUIT, onsig); - (void)signal(SIGPIPE, SIG_IGN); for (i = 0; i < AFCOUNT; i++) if (msocks[i] >= 0) { -- 1.7.8.3 From MAILER-DAEMON Sat Jan 14 08:01:31 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rm3Eh-0001Up-9E for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 08:01:31 -0500 Received: from eggs.gnu.org ([140.186.70.92]:55259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm3Ee-0001ST-Rw for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 08:01:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm3Ed-0007td-Vl for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 08:01:28 -0500 Received: from moutng.kundenserver.de ([212.227.17.9]:49189) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm3Ed-0007tX-I1 for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 08:01:27 -0500 Received: from obiwan.localnet (agsb-4d048964.pool.mediaWays.net [77.4.137.100]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0Mg2HB-1RzzDk0y5l-00O05u; Sat, 14 Jan 2012 14:01:25 +0100 From: Eckhart =?ISO-8859-1?Q?W=F6rner?= To: gpsd-dev@nongnu.org Date: Sat, 14 Jan 2012 14:01:24 +0100 Message-ID: <2963036.3ma8XA9ZPS@obiwan> User-Agent: KMail/4.8 rc2 (Linux/3.2.0-8-generic; KDE/4.7.97; x86_64; ; ) In-Reply-To: <1326539993-15588-1-git-send-email-vapier@gentoo.org> References: <1326539993-15588-1-git-send-email-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" X-Provags-ID: V02:K0:90ErQsfSt9h4UBfAxGznbKk1IQ1jgWpPciL2/BVlS8E QcUUYRb65VbRsFvq5szk+R0qHeVkt/89yUX1P/oUC6wehxfBSX 2i8KyxPn/hjnKxlq4ucw956SPfMmnRduPoHEmi34YGxo0QxM5E eSk5gyfQ3nMhdO/+mwn3hmEqGSEgmdDi/Pmh+CCZEwLTuRB59m nse1VNwJAEAjRIA9R8vTq8mHgbx4/0Ek5k5SLFL8JSR4Mk0AhO dAwHyAri6QAnA6tsk6jg6Qll7CnrZaJs8fbc7a9mY8D0kzcwX8 +YF4sVbZP9B7zE5e7y6WIFUrvQNa4YDPk7dmUZeXaw7CInPPQ= = X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.9 Subject: Re: [gpsd-dev] [PATCH] gpsd: use sigaction() to register signals X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 13:01:29 -0000 Hi Mike, Am Samstag, 14. Januar 2012, 06:19:53 schrieb Mike Frysinger: > We want to avoid the unportable signal() semantics wrt handlers being > reset upon signal delivery. > > Signed-off-by: Mike Frysinger > --- > note: only lightly tested with `./gpsd -N` and running `kill` > > gpsd.c | 18 ++++++++++++------ > 1 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/gpsd.c b/gpsd.c > index d342f5a..2a0855c 100644 you should probably refresh your patch. Eric has already pushed my pselect() changes. Eckhart From MAILER-DAEMON Sat Jan 14 08:08:04 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rm3L2-0001v4-4S for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 08:08:04 -0500 Received: from eggs.gnu.org ([140.186.70.92]:57971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm3L0-0001uy-7F for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 08:08:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm3Kz-00005X-7H for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 08:08:02 -0500 Received: from moutng.kundenserver.de ([212.227.126.186]:51878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm3Ky-00005O-Rs for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 08:08:01 -0500 Received: from obiwan.localnet (agsb-4d048964.pool.mediaWays.net [77.4.137.100]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0LaHLm-1SXzKT3VgU-00mEBP; Sat, 14 Jan 2012 14:07:59 +0100 From: Eckhart =?ISO-8859-1?Q?W=F6rner?= To: gpsd-dev@nongnu.org Date: Sat, 14 Jan 2012 14:07:59 +0100 Message-ID: <2042836.O9Qt2kB8uz@obiwan> User-Agent: KMail/4.8 rc2 (Linux/3.2.0-8-generic; KDE/4.7.97; x86_64; ; ) In-Reply-To: References: <3587273.FZPhh6N4pi@obiwan> <201201132229.40903.vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Provags-ID: V02:K0:tBcieEQHhSGlWqSEnebz43tpF4vt2K8fGd4le+kSBpY cqvnMZowzLsxuAjAE63pXzCvp0R89cMv2jrsFW/XwcCpUq9/LF icZuFVcHJUkczOC9+twAVX/140+yvPVBaMcA6XDgjRBniIyQsF Ej1qsLEXR04xB9NwrFaKGdkTFMHlc8gihBMIbiPa8gUAtlabfx EFT5LVswfYjghR1FUTjx+QaslNuG/azjN9WL02SiNjsTfJmdC+ CS5YNJPWuz2HFRO1As1BKggetTBKU+k8BrtQJSGSiD17f3YrXX kJVjwW2LkFDpivEK/M3iAPmFJUzbcJbkZ+tOfi3XVMHytOV5g= = X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.126.186 Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 13:08:03 -0000 Hi H=C3=A5kan, Am Samstag, 14. Januar 2012, 06:43:08 schrieb H=C3=A5kan Johansson: > Regarding (p)select and signal races, I did not see the 'self-pipe tr= ick' > mentioned in the discussion. Quoting > http://www.kernel.org/doc/man-pages/online/pages/man2/select.2.html: >=20 > "On systems that lack pselect(), reliable (and more portable) signal > trapping can be achieved using the self-pipe trick (where a signal ha= ndler > writes a byte to a pipe whose other end is monitored by select() in t= he > main program.)" I considered using that trick myself, but I refrained from doing so sin= ce the=20 trick requires a lot of extra code and in general is not that easy to g= et=20 right. [1] contains a discussion of all the steps required. Eckhart [1] http://lwn.net/Articles/177897/ From MAILER-DAEMON Sat Jan 14 08:53:53 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rm43N-0006Ra-PX for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 08:53:53 -0500 Received: from eggs.gnu.org ([140.186.70.92]:52333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm43L-0006RK-C7 for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 08:53:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm43K-0005qL-8e for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 08:53:51 -0500 Received: from fnord.ir.bbn.com ([192.1.100.210]:52260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm43K-0005qF-33 for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 08:53:50 -0500 Received: by fnord.ir.bbn.com (Postfix, from userid 10853) id 215065336; Sat, 14 Jan 2012 08:53:48 -0500 (EST) From: Greg Troxel To: Mike Frysinger References: <3587273.FZPhh6N4pi@obiwan> <201201132229.40903.vapier@gentoo.org> <201201140125.45555.vapier@gentoo.org> OpenPGP: id=32611E25 X-Hashcash: 1:20:120114:vapier@gentoo.org::ciyL0kyMHATIYXdQ:0000000000000000000000000000000000000000000025eZ X-Hashcash: 1:20:120114:gpsd-dev@nongnu.org::gXEue+ojkm/9laWn:000000000000000000000000000000000000000000Aa0A Date: Sat, 14 Jan 2012 08:53:37 -0500 In-Reply-To: <201201140125.45555.vapier@gentoo.org> (Mike Frysinger's message of "Sat, 14 Jan 2012 01:25:45 -0500") Message-ID: User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.1.100.210 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 13:53:52 -0000 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mike Frysinger writes: > On Saturday 14 January 2012 00:43:08 H=C3=A5kan Johansson wrote: >> Regarding (p)select and signal races, I did not see the 'self-pipe trick' >> mentioned in the discussion. Quoting >> http://www.kernel.org/doc/man-pages/online/pages/man2/select.2.html: >>=20 >> "On systems that lack pselect(), reliable (and more portable) signal >> trapping can be achieved using the self-pipe trick (where a signal handl= er >> writes a byte to a pipe whose other end is monitored by select() in the >> main program.)" > > neat trick, but i wonder if we even have to bother. pselect() has > been in the Linux kernel (and thus race free) for almost 6 years. the > select() based code, while admittedly racy, isn't that big of a deal > -- at worse, the code takes 1 second to respond. i think this is an > acceptable trade off -- install a kernel from the last 6 years, or > suck it up ;). gpsd does not specify Linux as a requirement; it is in theory portable to any reasonable posix-like system (which perhaps includes windows, and perhaps doesn't). But, pselect is specified by posix: http://pubs.opengroup.org/onlinepubs/009695399/functions/select.html and is available in NetBSD 5 (perhaps earlier) and FreeBSD from 2002 (and also in OS X 10.7, with the same FreeBSD man page), so I don't see any issue in relying on it. --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (NetBSD) iEYEARECAAYFAk8RiOIACgkQ+vesoDJhHiVsnQCgn4nXhr5DnZiKRP0CUaILS2Xl i5UAoJQw6XuA4rxrOstMRgogWXAQsXt2 =XVLb -----END PGP SIGNATURE----- --=-=-=-- From MAILER-DAEMON Sat Jan 14 10:14:35 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rm5JT-0004Bk-Oe for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 10:14:35 -0500 Received: from eggs.gnu.org ([140.186.70.92]:55915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm5JQ-0004BQ-MO for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 10:14:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm5JP-0008R1-9M for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 10:14:32 -0500 Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5]:55437 helo=snark.thyrsus.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm5JP-0008Qx-6m for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 10:14:31 -0500 Received: by snark.thyrsus.com (Postfix, from userid 1000) id 3D60E42A47; Sat, 14 Jan 2012 10:14:21 -0500 (EST) Date: Sat, 14 Jan 2012 10:14:21 -0500 From: "Eric S. Raymond" To: Greg Troxel Message-ID: <20120114151420.GA12178@thyrsus.com> References: <3587273.FZPhh6N4pi@obiwan> <201201132229.40903.vapier@gentoo.org> <201201140125.45555.vapier@gentoo.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: Organization: Eric Conspiracy Secret Labs X-Eric-Conspiracy: There is no conspiracy User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 71.162.243.5 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: esr@thyrsus.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 15:14:34 -0000 --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greg Troxel : > But, pselect is specified by posix: >=20 > http://pubs.opengroup.org/onlinepubs/009695399/functions/select.html >=20 > and is available in NetBSD 5 (perhaps earlier) and FreeBSD from 2002 > (and also in OS X 10.7, with the same FreeBSD man page), so I don't see > any issue in relying on it. Er, openbsd. pselect() only would be a crash landing for Chris Kuethe. It's not a problem, though. pselect() is easy to check for; the autonfiguration in scons took me a whole 3 minutes to write, and keeping the select() code path adds only a very little complexity. The work Mike Frysinger and are are doing on cleaning up the=20 signal handling should reduce that increment. --=20 Eric S. Raymond --9jxsPFA5p3P2qPhR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iD8DBQFPEZvMrfUW04Qh8RwRAqN7AJ9k3DoDB0f+E2vACunQ991ek7kExgCeLJML GTuppDvYr60sGiNUlecpu74= =Xmbs -----END PGP SIGNATURE----- --9jxsPFA5p3P2qPhR-- From MAILER-DAEMON Sat Jan 14 10:17:49 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rm5Mb-0004pA-Iy for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 10:17:49 -0500 Received: from eggs.gnu.org ([140.186.70.92]:56421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm5MZ-0004p3-J7 for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 10:17:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm5MY-0000LF-G4 for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 10:17:47 -0500 Received: from fnord.ir.bbn.com ([192.1.100.210]:52093) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm5MY-0000L6-D8 for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 10:17:46 -0500 Received: by fnord.ir.bbn.com (Postfix, from userid 10853) id 969EE52F9; Sat, 14 Jan 2012 10:17:45 -0500 (EST) From: Greg Troxel To: esr@thyrsus.com References: <3587273.FZPhh6N4pi@obiwan> <201201132229.40903.vapier@gentoo.org> <201201140125.45555.vapier@gentoo.org> <20120114151420.GA12178@thyrsus.com> OpenPGP: id=32611E25 X-Hashcash: 1:20:120114:gpsd-dev@nongnu.org::KOmOO595mo1J94mQ:0000000000000000000000000000000000000000009fZF X-Hashcash: 1:20:120114:vapier@gentoo.org::KOmOO595mo1J94mQ:00000000000000000000000000000000000000000000CD8S Date: Sat, 14 Jan 2012 10:17:45 -0500 In-Reply-To: <20120114151420.GA12178@thyrsus.com> (Eric S. Raymond's message of "Sat, 14 Jan 2012 10:14:21 -0500") Message-ID: User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.1.100.210 Cc: gpsd-dev@nongnu.org Subject: Re: [gpsd-dev] [PATCH] Use pselect() to reduce wakeups and avoid race conditions X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 15:17:48 -0000 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable "Eric S. Raymond" writes: >> Greg Troxel : >> But, pselect is specified by posix: >>=20 >> http://pubs.opengroup.org/onlinepubs/009695399/functions/select.html >>=20 >> and is available in NetBSD 5 (perhaps earlier) and FreeBSD from 2002 >> (and also in OS X 10.7, with the same FreeBSD man page), so I don't see >> any issue in relying on it. > > Er, openbsd. pselect() only would be a crash landing for Chris Kuethe. Indeed - sorry, I didn't mean to leave that out, I just didn't have it handy to check. > It's not a problem, though. pselect() is easy to check for; the > autonfiguration in scons took me a whole 3 minutes to write, and > keeping the select() code path adds only a very little complexity. > The work Mike Frysinger and are are doing on cleaning up the=20 > signal handling should reduce that increment. Certainly using it when present and coping without is totally reasonable. --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (NetBSD) iEYEARECAAYFAk8RnJkACgkQ+vesoDJhHiU4PgCglhT68mICMawkupb3oDJdlCE0 +eUAoJQufN7irqP07FbR5XZUW/V3FV0z =RrTz -----END PGP SIGNATURE----- --=-=-=-- From MAILER-DAEMON Sat Jan 14 16:28:25 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RmB9F-0008BL-9a for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 16:28:25 -0500 Received: from eggs.gnu.org ([140.186.70.92]:37259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmB9C-0008BD-QT for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 16:28:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RmB9B-0008Ud-Un for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 16:28:22 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:34930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmB9B-0008UZ-QO for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 16:28:21 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id E34C21B4049 for ; Sat, 14 Jan 2012 21:28:19 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: gpsd-dev@nongnu.org Date: Sat, 14 Jan 2012 16:28:18 -0500 User-Agent: KMail/1.13.7 (Linux/3.2.0; KDE/4.6.5; x86_64; ; ) References: <1326539993-15588-1-git-send-email-vapier@gentoo.org> <2963036.3ma8XA9ZPS@obiwan> In-Reply-To: <2963036.3ma8XA9ZPS@obiwan> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart7950906.spsregFzd2"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201201141628.19201.vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Subject: Re: [gpsd-dev] [PATCH] gpsd: use sigaction() to register signals X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 21:28:23 -0000 --nextPart7950906.spsregFzd2 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Saturday 14 January 2012 08:01:24 Eckhart W=C3=B6rner wrote: > Am Samstag, 14. Januar 2012, 06:19:53 schrieb Mike Frysinger: > > We want to avoid the unportable signal() semantics wrt handlers being > > reset upon signal delivery. > >=20 > > Signed-off-by: Mike Frysinger > > --- > > note: only lightly tested with `./gpsd -N` and running `kill` > >=20 > > gpsd.c | 18 ++++++++++++------ > > 1 files changed, 12 insertions(+), 6 deletions(-) > >=20 > > diff --git a/gpsd.c b/gpsd.c > > index d342f5a..2a0855c 100644 >=20 > you should probably refresh your patch. Eric has already pushed my > pselect() changes. ah so he has, including the random issues raised on the list :/ =2Dmike --nextPart7950906.spsregFzd2 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPEfNzAAoJEEFjO5/oN/WBQP4P/1JnUqebuLKu5RyopJfH5OD4 quMUy8R641OV/LlNKv3jQYtToY02N5W6H3soFkTJnUGjr8xZMYvc+mIxL22r9A9J MZdDwLjM4okU6E1M9e3d7bqNmA2UNc0z5JfNPmwe0m13A2nx9J0HTKEQObqInsEi 0CTpn2fk/AJU6AXtXwmJ2Z9QJNtGS5FrOiO/At49KRuNp3tj/ywZfEHomlrmiicP 77KJu4L2PEH8NRMXXyaS6YdzpDLUOl1iL50OG/ZeeJoIuD4mA5pSq6k+GSKpyN52 D9UmZLNL8Khwuzh+uxpIKrsji95sEbgxeeze1qFu6NI99K4RvZ0UxhYK8U5Z1tTK 2M4q2UY9IziH+UEYg4w9xx+u82jslmZmGx5IeVBkvq3453QcCKEwOttG0Ex3iAgk oCcb6ltnYB5w+ciYZcErdVC6XuOArdFwvwRN28a2Sy2NjmNOvi+6JYDtboUmwxkq Nd/I5CmBQCWiNqGOWZNKX4r+K+RCC3gm9QCio4Otplo3uxBPdvoYFbfjc35TOfSU XjF/2AMWxDpTjis/a+1VxKi7uHN9Qndgdphed0yUz/ZS+qbiiyiSFo/xAAFHd4Te 8wknxj46t1xT3rCe6A+3SIloSMGlw+K1UcJ1Ju1hIksa5E0xpTQ4G5ePPS3b6SEB bF9YwI8O0j77LPTeB6ge =rvNk -----END PGP SIGNATURE----- --nextPart7950906.spsregFzd2-- From MAILER-DAEMON Sat Jan 14 16:36:33 2012 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RmBH7-00016U-KT for mharc-gpsd-dev@gnu.org; Sat, 14 Jan 2012 16:36:33 -0500 Received: from eggs.gnu.org ([140.186.70.92]:48372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmBH5-00014k-H3 for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 16:36:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RmBH4-000138-Dq for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 16:36:31 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:35330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmBH4-000134-9U for gpsd-dev@nongnu.org; Sat, 14 Jan 2012 16:36:30 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 969EA1B403D for ; Sat, 14 Jan 2012 21:36:28 +0000 (UTC) From: Mike Frysinger To: gpsd-dev@nongnu.org Date: Sat, 14 Jan 2012 16:36:28 -0500 Message-Id: <1326576988-22576-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1326539993-15588-1-git-send-email-vapier@gentoo.org> References: <1326539993-15588-1-git-send-email-vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 140.211.166.183 Subject: [gpsd-dev] [PATCH v2] gpsd: use sigaction() to register signals X-BeenThere: gpsd-dev@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 21:36:32 -0000 We want to avoid the unportable signal() semantics wrt handlers being reset upon signal delivery, so use sigaction() instead. While we're fixing this, we can move the signal setup logic outside of the setjmp loop since we no longer have to reset anything. We know the kernel will do the right thing. Also rename the incorrect "emptyset" to "oldset" to reflect what it actually represents. Signed-off-by: Mike Frysinger --- v2 - rebased and updated new pselect code too gpsd.c | 39 +++++++++++++++++++++++---------------- 1 files changed, 23 insertions(+), 16 deletions(-) diff --git a/gpsd.c b/gpsd.c index 7c44db8..29cdec1 100644 --- a/gpsd.c +++ b/gpsd.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #ifndef S_SPLINT_S #include @@ -1769,10 +1770,11 @@ int main(int argc, char *argv[]) #ifdef COMPAT_SELECT struct timeval tv; #else - sigset_t emptyset, blockset; + sigset_t oldset, blockset; #endif /* COMPAT_SELECT */ const struct gps_type_t **dp; bool in_restart; + struct sigaction sa; #ifdef PPS_ENABLE /*@-nullpass@*/ @@ -2043,6 +2045,25 @@ int main(int argc, char *argv[]) subscribers[i].fd = UNALLOCATED_FD; #endif /* SOCKET_EXPORT_ENABLE*/ + /* Handle some signals */ +#ifndef COMPAT_SELECT + (void)sigemptyset(&blockset); + (void)sigaddset(&blockset, SIGHUP); + (void)sigaddset(&blockset, SIGINT); + (void)sigaddset(&blockset, SIGTERM); + (void)sigaddset(&blockset, SIGQUIT); + (void)sigprocmask(SIG_BLOCK, &blockset, &oldset); +#endif /* COMPAT_SELECT */ + + sa.sa_flags = 0; + sa.sa_handler = onsig; + (void)sigfillset(&sa.sa_mask); + (void)sigaction(SIGHUP, &sa, NULL); + (void)sigaction(SIGINT, &sa, NULL); + (void)sigaction(SIGTERM, &sa, NULL); + (void)sigaction(SIGQUIT, &sa, NULL); + (void)signal(SIGPIPE, SIG_IGN); + /* daemon got termination or interrupt signal */ if (setjmp(restartbuf) > 0) { /* try to undo all device configurations */ @@ -2054,21 +2075,7 @@ int main(int argc, char *argv[]) gpsd_report(LOG_WARN, "gpsd restarted by SIGHUP\n"); } - /* Handle some signals */ -#ifndef COMPAT_SELECT - (void)sigemptyset(&blockset); - (void)sigaddset(&blockset, SIGHUP); - (void)sigaddset(&blockset, SIGINT); - (void)sigaddset(&blockset, SIGTERM); - (void)sigaddset(&blockset, SIGQUIT); - (void)sigprocmask(SIG_BLOCK, &blockset, &emptyset); -#endif /* COMPAT_SELECT */ signalled = 0; - (void)signal(SIGHUP, onsig); - (void)signal(SIGINT, onsig); - (void)signal(SIGTERM, onsig); - (void)signal(SIGQUIT, onsig); - (void)signal(SIGPIPE, SIG_IGN); for (i = 0; i < AFCOUNT; i++) if (msocks[i] >= 0) { @@ -2116,7 +2123,7 @@ int main(int argc, char *argv[]) tv.tv_usec = 0; if (select(maxfd + 1, &rfds, NULL, NULL, &tv) == -1) { #else - if (pselect(maxfd + 1, &rfds, NULL, NULL, NULL, &emptyset) == -1) { + if (pselect(maxfd + 1, &rfds, NULL, NULL, NULL, &oldset) == -1) { #endif if (errno == EINTR) continue; -- 1.7.8.3