From: Thomas E. Dickey Date: Sun, 2 Mar 2008 00:28:54 +0000 (+0000) Subject: ncurses 5.6 - patch 20080301 X-Git-Tag: v5.7~34 X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=176aaa579a65f28a5fab489b89c9948bb28d4c08;ds=sidebyside ncurses 5.6 - patch 20080301 + fixes from 20080223 resolved issue with mutexes; change to use recursive mutexes to fix memory leak in delwin() as called from _nc_free_and_exit(). --- diff --git a/NEWS b/NEWS index 5634dbc3..39613f05 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1208 2008/02/23 21:26:58 tom Exp $ +-- $Id: NEWS,v 1.1209 2008/03/01 20:02:41 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,11 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20080301 + + fixes from 20080223 resolved issue with mutexes; change to use + recursive mutexes to fix memory leak in delwin() as called from + _nc_free_and_exit(). + 20080223 + fix a size-difference in _nc_globals which caused hanging of mutex lock/unlock when termlib was built separately. diff --git a/dist.mk b/dist.mk index 4bc5ab05..b848f037 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.631 2008/02/23 14:51:29 tom Exp $ +# $Id: dist.mk,v 1.632 2008/03/01 16:53:24 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 5 NCURSES_MINOR = 6 -NCURSES_PATCH = 20080223 +NCURSES_PATCH = 20080301 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index ddf15a8a..fa478596 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ /* - * $Id: curses.priv.h,v 1.359 2008/02/23 21:19:56 tom Exp $ + * $Id: curses.priv.h,v 1.360 2008/03/01 20:36:39 tom Exp $ * * curses.priv.h * @@ -351,6 +351,14 @@ extern NCURSES_EXPORT(void) _nc_unlock_window(WINDOW *); #define _nc_lock_screen(name) /* nothing */ #define _nc_unlock_screen(name) /* nothing */ +#if HAVE_GETTIMEOFDAY +# define PRECISE_GETTIME 1 +# define TimeType struct timeval +#else +# define PRECISE_GETTIME 0 +# define TimeType time_t +#endif + /* * Definitions for color pairs */ diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c index e3affe40..a13113c6 100644 --- a/ncurses/tinfo/lib_data.c +++ b/ncurses/tinfo/lib_data.c @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: lib_data.c,v 1.40 2008/02/23 21:23:44 tom Exp $") +MODULE_ID("$Id: lib_data.c,v 1.42 2008/03/02 00:04:32 tom Exp $") /* * OS/2's native linker complains if we don't initialize public data when @@ -234,31 +234,59 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = { /******************************************************************************/ #ifdef USE_PTHREADS +static void +init_global_mutexes(void) +{ + static bool initialized = FALSE; + + if (!initialized) { + initialized = TRUE; + _nc_mutex_init(&_nc_globals.mutex_set_SP); + _nc_mutex_init(&_nc_globals.mutex_use_screen); + _nc_mutex_init(&_nc_globals.mutex_use_window); + _nc_mutex_init(&_nc_globals.mutex_windowlist); + _nc_mutex_init(&_nc_globals.mutex_tst_tracef); + _nc_mutex_init(&_nc_globals.mutex_tracef); + } +} + +/* + * Use recursive mutexes if we have them - they're part of Unix98. + * For the cases where we do not, _nc_mutex_trylock() is used to avoid a + * deadlock, at the expense of memory leaks and unexpected failures that + * may not be handled by typical clients. + * + * FIXME - need configure check for PTHREAD_MUTEX_RECURSIVE, define it to + * PTHREAD_MUTEX_NORMAL if not supported. + */ NCURSES_EXPORT(void) _nc_mutex_init(pthread_mutex_t * obj) { pthread_mutexattr_t recattr; memset(&recattr, 0, sizeof(recattr)); - pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_NORMAL); + pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(obj, &recattr); } NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t * obj) { + init_global_mutexes(); return pthread_mutex_lock(obj); } NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t * obj) { + init_global_mutexes(); return pthread_mutex_trylock(obj); } NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t * obj) { + init_global_mutexes(); return pthread_mutex_unlock(obj); } #endif /* USE_PTHREADS */ diff --git a/ncurses/tty/lib_twait.c b/ncurses/tty/lib_twait.c index 1e4546de..ec9daae8 100644 --- a/ncurses/tty/lib_twait.c +++ b/ncurses/tty/lib_twait.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -62,15 +62,7 @@ # endif #endif -MODULE_ID("$Id: lib_twait.c,v 1.54 2007/08/11 16:32:48 tom Exp $") - -#if HAVE_GETTIMEOFDAY -# define PRECISE_GETTIME 1 -# define TimeType struct timeval -#else -# define PRECISE_GETTIME 0 -# define TimeType time_t -#endif +MODULE_ID("$Id: lib_twait.c,v 1.55 2008/03/01 22:08:31 tom Exp $") static long _nc_gettime(TimeType * t0, bool first)