Opened 11 years ago

Closed 11 years ago

#6200 closed Patches (fixed)

patch to have condition_variable and mutex error better handle EINTR

Reported by: blentz@… Owned by: viboes
Milestone: Boost 1.49.0 Component: thread
Version: Boost Development Trunk Severity: Problem
Keywords: 1.49 thread mutex eintr phusion passenger Cc: viboes

Description

On some flavors of Linux, for some versions of the pthread library, there are cases where it erroneously sends EINTR. This is a violation of POSIX, but it exists on some customer's production machines.

BOOST_VERIFY aborts on EINTR, but EINTR is usually not fatal, it just means you need to try later. Being that this behavior was found in production, I believe that it would be valuable to have Boost help protect downstream consumers from bad threading library behavior. This allows downstream consumers of Boost to not need to continuously rediscover and re-patch for this same bug.

So, with this in mind, attached is a proposed patch to allow condition_variable and mutex to better handle interacting with this potentially broken threading library behavior.

Attachments (1)

thread_eintr.patch (2.7 KB ) - added by blentz@… 11 years ago.
patch to correct for receiving EINTR in condition_variable and mutex.

Download all attachments as: .zip

Change History (6)

by blentz@…, 11 years ago

Attachment: thread_eintr.patch added

patch to correct for receiving EINTR in condition_variable and mutex.

comment:1 by viboes, 11 years ago

Cc: viboes added
Keywords: 1.49 added
Owner: changed from Anthony Williams to viboes
Status: newassigned

This part is not correct

        55	res=pthread_cond_wait(&cond,&internal_mutex); 

 	55	int ret; 
 	56	do { 
 	57	  ret = pthread_cond_wait(&cond,m.mutex()->native_handle()); 
 	58	} while (ret == EINTR); 

Note that before the mutex used was internal_mutex. Are you sure that this patch is working for your applications?

comment:2 by viboes, 11 years ago

Milestone: To Be DeterminedBoost 1.49.0

Committed in trunk revision [75781] condition variable part.

Last edited 9 years ago by viboes (previous) (diff)

comment:3 by blentz@…, 11 years ago

It looks like only the condition_variable and condition_variable_fwd portion of the patch was committed.

The changes to mutex are missing in revision 75781.

Was this done by choice or is it an oversight?

comment:4 by viboes, 11 years ago

Committed in trunk revision [75882] mutex part

Last edited 9 years ago by viboes (previous) (diff)

comment:5 by viboes, 11 years ago

Resolution: fixed
Status: assignedclosed

Committed in release at [76291]

Last edited 9 years ago by viboes (previous) (diff)
Note: See TracTickets for help on using tickets.