Commit 84706343 by Benjamin Kosnik Committed by Benjamin Kosnik

re PR libstdc++/17780 (std::allocator vs. static init)


2004-10-06  Benjamin Kosnik  <bkoz@redhat.com>
	    Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/17780
	* src/mt_allocator.cc (__pool<true>::_M_reserve_block): Revert
	to old locking order.

Co-Authored-By: Paolo Carlini <pcarlini@suse.de>

From-SVN: r88611
parent 3b0cff13
2004-10-06 Benjamin Kosnik <bkoz@redhat.com>
Paolo Carlini <pcarlini@suse.de>
PR libstdc++/17780
* src/mt_allocator.cc (__pool<true>::_M_reserve_block): Revert
to old locking order.
2004-10-06 Paolo Carlini <pcarlini@suse.de> 2004-10-06 Paolo Carlini <pcarlini@suse.de>
* include/std/std_sstream.h (_M_sync): When the caller is * include/std/std_sstream.h (_M_sync): When the caller is
......
...@@ -298,10 +298,13 @@ namespace __gnu_cxx ...@@ -298,10 +298,13 @@ namespace __gnu_cxx
_Block_record* __block = NULL; _Block_record* __block = NULL;
if (__gthread_active_p()) if (__gthread_active_p())
{ {
__gthread_mutex_lock(__bin._M_mutex);
if (__bin._M_first[0] == NULL) if (__bin._M_first[0] == NULL)
{ {
// No need to hold the lock when we are adding a whole // No need to hold the lock when we are adding a whole
// chunk to our own list. // chunk to our own list.
__gthread_mutex_unlock(__bin._M_mutex);
void* __v = ::operator new(__options._M_chunk_size); void* __v = ::operator new(__options._M_chunk_size);
__bin._M_first[__thread_id] = static_cast<_Block_record*>(__v); __bin._M_first[__thread_id] = static_cast<_Block_record*>(__v);
__bin._M_free[__thread_id] = __block_count; __bin._M_free[__thread_id] = __block_count;
...@@ -327,7 +330,6 @@ namespace __gnu_cxx ...@@ -327,7 +330,6 @@ namespace __gnu_cxx
// Is the number of required blocks greater than or equal // Is the number of required blocks greater than or equal
// to the number that can be provided by the global free // to the number that can be provided by the global free
// list? // list?
__gthread_mutex_lock(__bin._M_mutex);
__bin._M_first[__thread_id] = __bin._M_first[0]; __bin._M_first[__thread_id] = __bin._M_first[0];
if (__block_count >= __bin._M_free[0]) if (__block_count >= __bin._M_free[0])
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment