From owner-svn-src-all@FreeBSD.ORG Thu Oct 29 11:00:40 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BB53106566C; Thu, 29 Oct 2009 11:00:40 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 297678FC2E; Thu, 29 Oct 2009 11:00:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TB0eCM093815; Thu, 29 Oct 2009 11:00:40 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TB0eIo093813; Thu, 29 Oct 2009 11:00:40 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910291100.n9TB0eIo093813@svn.freebsd.org> From: Edwin Groothuis Date: Thu, 29 Oct 2009 11:00:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198579 - in stable/7/lib/libc: . stdtime X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2009 11:00:40 -0000 Author: edwin Date: Thu Oct 29 11:00:39 2009 New Revision: 198579 URL: http://svn.freebsd.org/changeset/base/198579 Log: MFC of r197189 Improve the way failure of pthread_key_create() gets detected. PR: threads/138603 Submitted by: Mikulas Patocka Modified: stable/7/lib/libc/ (props changed) stable/7/lib/libc/stdtime/localtime.c Modified: stable/7/lib/libc/stdtime/localtime.c ============================================================================== --- stable/7/lib/libc/stdtime/localtime.c Thu Oct 29 10:38:17 2009 (r198578) +++ stable/7/lib/libc/stdtime/localtime.c Thu Oct 29 11:00:39 2009 (r198579) @@ -21,6 +21,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include #include +#include #include #include #include "private.h" @@ -1413,12 +1414,15 @@ const time_t * const timep; static pthread_mutex_t localtime_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_key_t localtime_key = -1; struct tm *p_tm; + int r; if (__isthreaded != 0) { _pthread_mutex_lock(&localtime_mutex); if (localtime_key < 0) { - if (_pthread_key_create(&localtime_key, free) < 0) { + if ((r = _pthread_key_create(&localtime_key, free)) + != 0) { _pthread_mutex_unlock(&localtime_mutex); + errno = r; return(NULL); } } @@ -1510,12 +1514,14 @@ const time_t * const timep; static pthread_mutex_t gmtime_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_key_t gmtime_key = -1; struct tm *p_tm; + int r; if (__isthreaded != 0) { _pthread_mutex_lock(&gmtime_mutex); if (gmtime_key < 0) { - if (_pthread_key_create(&gmtime_key, free) < 0) { + if ((r = _pthread_key_create(&gmtime_key, free)) != 0) { _pthread_mutex_unlock(&gmtime_mutex); + errno = r; return(NULL); } }