Date: Sat, 23 Jan 2010 20:34:35 +0100 From: Gabor Kovesdan <gabor@FreeBSD.org> To: Hajimu UMEMOTO <ume@FreeBSD.org> Cc: Kostik Belousov <kostikbel@gmail.com>, attilio@FreeBSD.org, current@FreeBSD.org Subject: Re: NLS/strerror efficiency Message-ID: <4B5B4F4B.3030201@FreeBSD.org> In-Reply-To: <yge1vhgvdd3.wl%ume@mahoroba.org> References: <20100119212019.GL59590@deviant.kiev.zoral.com.ua> <4B56CACF.50508@FreeBSD.org> <yge1vhgvdd3.wl%ume@mahoroba.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------000102010404010207030707 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit El 2010. 01. 23. 20:18, Hajimu UMEMOTO escribió: > The gai_strerror(3) has same issue. How about the attached patch in > this mail? > I have a fix for msgcat.c to optimalize catalog handling. As I'm not an src committer, delphij@ is helping me in reviewing and approving my patches. I've sent the attached patch to him today and I'm waiting for his response now. This patch caches the failing and the succesful catopen() calls in a thread-safe way and in the latter case it counts references to cached catalog. Still, I consider it a good idea to have a static catalog descriptor in strerror.3 and use that instead of always opening and closing the catalog. Regards, -- Gabor Kovesdan FreeBSD Volunteer EMAIL: gabor@FreeBSD.org .:|:. gabor@kovesdan.org WEB: http://people.FreeBSD.org/~gabor .:|:. http://kovesdan.org --------------000102010404010207030707 Content-Type: text/plain; name="nls-caching.diff" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="nls-caching.diff" SW5kZXg6IG5scy9tc2djYXQuYw0KPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLS0tIG5scy9tc2djYXQuYwko cmV2aXNp8246IDIwMjY1OCkNCisrKyBubHMvbXNnY2F0LmMJKGNvcGlhIGRlIHRyYWJham8p DQpAQCAtMzksNiArMzksNyBAQA0KICNpbmNsdWRlIDxzeXMvdHlwZXMuaD4NCi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F0ZW50cnkpKSkgIT0gTlVMTCkgew0KKwkJbnAtPm5hbWUgPSBzdHJkdXAobmFt ZSk7DQorCQlucC0+cGF0aCA9IHN0cmR1cChwYXRoKTsNCisJCW5wLT5jYXRkID0gY2F0ZDsN CisJCW5wLT5yZWZjb3VudCA9IDE7DQorCQlucC0+Y2F0ZXJybm8gPSAwOw0KKwkJU0xJU1Rf SU5TRVJUX0hFQUQoJmZsaXN0LCBucCwgbGlzdCk7DQorCX0NCisJVU5MT0NLKE5MRVJSKTsN CiAJcmV0dXJuIChjYXRkKTsNCiB9DQogDQo= --------------000102010404010207030707--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B5B4F4B.3030201>