Opened 6 years ago

Closed 6 years ago

#12486 closed Bugs (invalid)

system_error_code for thread safe

Reported by: lzwyg <lzwyg@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

if(!create_directory(root_shared_dir.c_str())){

error_info info(system_error_code()); if(info.get_error_code() != already_exists_error){

throw interprocess_exception(info);

}

}

If the directory exists, get last error is already_exists_error, but in the multi thread environment, last_error will be rewritten by another thread.

Whether this can be improved by compiler options?

test environment: MAC OS

Change History (3)

comment:1 by John Maddock, 6 years ago

Please specify which boost library you are using, and assign this ticket to the appropriate component - otherwise nothing will happen here!

comment:2 by anonymous, 6 years ago

Component: Noneinterprocess
Owner: set to Ion Gaztañaga

comment:3 by Ion Gaztañaga, 6 years ago

Resolution: invalid
Status: newclosed

get_last_error is a wrapper for errno in Unix systems. POSIX requires that errno be threadsafe so there is an errno value for each thread using thread specific data, no other thread can overwrite the last error for this thread.

Note: See TracTickets for help on using tickets.