Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
fixed broken errno on solaris
Browse files Browse the repository at this point in the history
accept() failed, but its errno got trashed by another another thread
which led to undefined behaviour.

root-cause was include <errno.h> provides a non-thread-local-storage
version if _POSIX_C_SOURCE isn't defined as atleast POSIX.1c
  • Loading branch information
weigon committed Jun 14, 2018
1 parent 195718c commit a6f9b05
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/mock_server/src/mysql_protocol_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

/*
* include climits first to ensure _POSIX_C_SOURCE will be set
* correctly early.
*
* On solaris sys/feature_set.h must be included before errno.h
* to ensure the right version of 'errno' is provided:
*
* - without _POSIX_C_SOURCE >= 199509L: 'extern int errno'
* - with, '*(___errno())', the thread-local-storage version.
*
* including climits is safe on all platforms AND includes
* sys/feature_set.h on solaris.
*/
#include <climits>
#include <system_error>

#ifndef _WIN32
Expand Down

0 comments on commit a6f9b05

Please sign in to comment.