]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.6 - patch 20080301
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 2 Mar 2008 00:28:54 +0000 (00:28 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 2 Mar 2008 00:28:54 +0000 (00:28 +0000)
+ 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().

NEWS
dist.mk
ncurses/curses.priv.h
ncurses/tinfo/lib_data.c
ncurses/tty/lib_twait.c

diff --git a/NEWS b/NEWS
index 5634dbc392d4f409f2064fde6ad05c82efac8190..39613f05ac0f70384738418fcbbc379eed27287d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
 -- 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
 -------------------------------------------------------------------------------
 
 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.
 
 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.
 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 4bc5ab059f73f909457456f5c5a8f208075f3442..b848f03762063057140861832849d46df128e0d4 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
 # 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
 # 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
 # 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)
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index ddf15a8a4eb4bb48bc6cb58f94bad03041050d13..fa47859659bf8da3d5f9db6627296c7428d58752 100644 (file)
@@ -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
  *
  *
  *     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 */
 
 #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
  */
 /*
  * Definitions for color pairs
  */
index e3affe40ee86c7709998a910e3655182efab170c..a13113c6bfa531e5e26339aa35ae4d4262d12083 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-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
 
 /*
  * 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
 
 /******************************************************************************/
 #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));
 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)
 {
     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)
 {
     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)
 {
     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 */
     return pthread_mutex_unlock(obj);
 }
 #endif /* USE_PTHREADS */
index 1e4546dec0c00517d6bef2e20fe8ce73386162c1..ec9daae80390e8d272711dc49bd1befffa959676 100644 (file)
@@ -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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 # endif
 #endif
 
 # 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)
 
 static long
 _nc_gettime(TimeType * t0, bool first)