[yast-commit] r60641 - in /branches/SuSE-Code-11-SP1-Branch/core: VERSION liby2util-r/src/y2log.cc liby2util-r/testsuite/Makefile.am liby2util-r/testsuite/test_thread_log.cc package/yast2-core.changes

Author: mvidner Date: Mon Feb 1 17:16:46 2010 New Revision: 60641 URL: http://svn.opensuse.org/viewcvs/yast?rev=60641&view=rev Log: Fixed a crash in LogTail by adding a mutex to the shared variable (bnc#565918). Added: branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/test_thread_log.cc Modified: branches/SuSE-Code-11-SP1-Branch/core/VERSION branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/src/y2log.cc branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/Makefile.am branches/SuSE-Code-11-SP1-Branch/core/package/yast2-core.changes Modified: branches/SuSE-Code-11-SP1-Branch/core/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/core/V... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/core/VERSION (original) +++ branches/SuSE-Code-11-SP1-Branch/core/VERSION Mon Feb 1 17:16:46 2010 @@ -1 +1 @@ -2.17.32 +2.17.33 Modified: branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/src/y2log.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/core/l... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/src/y2log.cc (original) +++ branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/src/y2log.cc Mon Feb 1 17:16:46 2010 @@ -322,7 +322,10 @@ else tolog = y2_logfmt_prefix (level) + common; // store the message for worse times + static pthread_mutex_t blanik_mutex = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_lock (&blanik_mutex); blanik.push_back (tolog); + pthread_mutex_unlock (&blanik_mutex); } } Modified: branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/core/l... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/Makefile.am (original) +++ branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/Makefile.am Mon Feb 1 17:16:46 2010 @@ -16,12 +16,16 @@ noinst_PROGRAMS = \ test_Y2SLog \ + test_thread_log.prg \ test_strutil \ test_mkdir.prg \ test_chroot.prg test_Y2SLog_SOURCES = test_Y2SLog.cc +test_thread_log_prg_SOURCES = test_thread_log.cc +test_thread_log_prg_LDFLAGS = $(AM_LDFLAGS) -pthread + test_strutil_SOURCES = test_strutil.cc test_mkdir_prg_SOURCES = test_mkdir.cc Added: branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/test_thread_log.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/core/l... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/test_thread_log.cc (added) +++ branches/SuSE-Code-11-SP1-Branch/core/liby2util-r/testsuite/test_thread_log.cc Mon Feb 1 17:16:46 2010 @@ -0,0 +1,44 @@ +// adapted from +// http://en.wikipedia.org/wiki/POSIX_Threads#Example +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#define NUM_THREADS 5 + +#include <y2util/y2log.h> + +int ticks; + +void *PrintHello(void *threadid) +{ + long tid; + + + tid = (long)threadid; + printf("Hello World! It's me, thread %p!\n", threadid); + for (int i = 0; i < ticks; ++i) + y2debug("Thread %p tick %d", threadid, i); + pthread_exit(NULL); +} + +int main (int argc, char *argv[]) +{ + pthread_t threads[NUM_THREADS]; + + setenv("Y2DEBUGONCRASH", "1", 1 /*overwrite*/); + ticks = argv[1]? atoi(argv[1]): 1000; + int rc; + intptr_t t; + for(t=1; t<=NUM_THREADS; t++){ + printf("In main: creating thread %p\n", (void*)t); + rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t); + + + if (rc){ + printf("ERROR; return code from pthread_create() is %d\n", rc); + exit(-1); + } + } + pthread_exit(NULL); +} + Modified: branches/SuSE-Code-11-SP1-Branch/core/package/yast2-core.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/core/p... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/core/package/yast2-core.changes (original) +++ branches/SuSE-Code-11-SP1-Branch/core/package/yast2-core.changes Mon Feb 1 17:16:46 2010 @@ -1,7 +1,10 @@ ------------------------------------------------------------------- Mon Feb 1 16:01:46 CET 2010 - mvidner@suse.cz +- Fixed a crash in LogTail by adding a mutex to the shared variable + (bnc#565918). - Re-enabled parts of liby2util-r testsuite. +- 2.17.33 ------------------------------------------------------------------- Mon Feb 1 15:50:51 CET 2010 - mvidner@suse.cz -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
mvidner@svn.opensuse.org