Code

Fix errno thread-safety under AIX
authorAurelien Reynaud <collectd@wattapower.net>
Sat, 19 Jun 2010 18:03:52 +0000 (20:03 +0200)
committerFlorian Forster <octo@huhu.verplant.org>
Sat, 11 Sep 2010 09:08:47 +0000 (11:08 +0200)
commit13cbf9d48f26083e29e07c1b59ad1d67b6efa147
tree6a51180e5d85a3c5cbf0cf3d646e147cfbdc65dd
parentabca4ca8259e09e4a195d1741e8aec32fa800b62
Fix errno thread-safety under AIX

Unlike Linux or Solaris, errno under AIX is not thread-safe by
default.

This patch sets _THREAD_SAFE_ERRNO when AIX is detected in order to
force the thread-safe implementation of errno. Without this, calls
like stat() in the rrdtool plugin fail with errno incorrectly set,
leading to the inability to create previously absent rrd files.

Maybe _THREAD_SAFE should be set instead, to prevent other possible
threads-related problems, but this is enough to scratch my current
itch...

Here is the relevant part of /usr/include/errno.h on AIX:

 #if defined(_THREAD_SAFE) || defined(_THREAD_SAFE_ERRNO)
 /*
  * Per thread errno is provided by the threads provider. Both the extern
  * int
  * and the per thread value must be maintained by the threads library.
  */
 extern  int     *_Errno( void );
 #define errno   (*_Errno())

 #else

 extern int errno;

 #endif  /* _THREAD_SAFE || _THREAD_SAFE_ERRNO */

Signed-off-by: Aurelien Reynaud <collectd@wattapower.net>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
configure.in