mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-27 03:20:22 +08:00
Rework <ac/errno.h> to provide a STRERROR. Prefers errlist over
strerror() as strerror() may not be thread safe. Likely should be used by SLAPD.
This commit is contained in:
parent
489fd210df
commit
4f4f59f333
@ -25,15 +25,27 @@
|
||||
# define sys_errlist ((char **)0)
|
||||
#elif DECL_SYS_ERRLIST
|
||||
/* have sys_errlist but need declaration */
|
||||
LDAP_LIBC_V (int) sys_nerr;
|
||||
LDAP_LIBC_V (char) *sys_errlist[];
|
||||
LDAP_LIBC_V(int) sys_nerr;
|
||||
LDAP_LIBC_V(char) *sys_errlist[];
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRERROR
|
||||
#define STRERROR(err) strerror(err)
|
||||
#undef _AC_ERRNO_UNKNOWN
|
||||
#define _AC_ERRNO_UNKNOWN "unknown error"
|
||||
|
||||
#ifdef HAVE_SYS_ERRLIST
|
||||
/* this is thread safe */
|
||||
# define STRERROR(e) ( (e) > -1 && (e) < sys_nerr \
|
||||
? sys_errlist[(e)] : _AC_ERRNO_UNKNOWN )
|
||||
|
||||
#elif defined( HAVE_STRERROR )
|
||||
/* this may not be thread safe */
|
||||
/* and, yes, some implementations of strerror may return NULL */
|
||||
# define STRERROR(e) ( strerror(e) \
|
||||
? strerror(e) : _AC_ERRNO_UNKNOWN )
|
||||
|
||||
#else
|
||||
#define STRERROR(err) \
|
||||
((err) > -1 && (err) < sys_nerr ? sys_errlist[(err)] : "unknown")
|
||||
/* this is thread safe */
|
||||
# define STRERROR(e) ( _AC_ERRNO_UNKNOWN )
|
||||
#endif
|
||||
|
||||
#endif /* _AC_ERRNO_H */
|
||||
|
@ -914,7 +914,7 @@ sb_debug_read( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len )
|
||||
if ( ret < 0 ) {
|
||||
ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
|
||||
"%sread: want=%ld error=%s\n", (char *)sbiod->sbiod_pvt,
|
||||
(long)len, strerror( errno ) );
|
||||
(long)len, STRERROR( errno ) );
|
||||
}
|
||||
else {
|
||||
ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
|
||||
@ -936,7 +936,7 @@ sb_debug_write( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len )
|
||||
ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
|
||||
"%swrite: want=%ld error=%s\n",
|
||||
(char *)sbiod->sbiod_pvt, (long)len,
|
||||
strerror( errno ) );
|
||||
STRERROR( errno ) );
|
||||
}
|
||||
else {
|
||||
ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
|
||||
|
@ -83,7 +83,7 @@ ldap_pvt_close_socket(LDAP *ld, int s)
|
||||
"ldap_is_socket_ready: errror on socket %d: errno: %d (%s)\n", \
|
||||
s, \
|
||||
errno, \
|
||||
strerror(errno) ); \
|
||||
STRERROR(errno) ); \
|
||||
} while( 0 )
|
||||
|
||||
/*
|
||||
|
@ -135,11 +135,8 @@ int ldbm_initialize( void )
|
||||
if ( err ) {
|
||||
char error[BUFSIZ];
|
||||
|
||||
if ( err < 0 ) {
|
||||
sprintf( error, "%ld\n", (long) err );
|
||||
} else {
|
||||
sprintf( error, "%s\n", strerror( err ));
|
||||
}
|
||||
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
|
||||
|
||||
#ifdef LDAP_SYSLOG
|
||||
syslog( LOG_INFO,
|
||||
"ldbm_initialize(): FATAL error in db_appinit() : %s\n",
|
||||
@ -158,11 +155,8 @@ int ldbm_initialize( void )
|
||||
{
|
||||
char error[BUFSIZ];
|
||||
|
||||
if ( err < 0 ) {
|
||||
sprintf( error, "%ld\n", (long) err );
|
||||
} else {
|
||||
sprintf( error, "%s\n", strerror( err ));
|
||||
}
|
||||
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
|
||||
|
||||
#ifdef LDAP_SYSLOG
|
||||
syslog( LOG_INFO,
|
||||
"ldbm_initialize(): FATAL error in db_appinit() : %s\n",
|
||||
@ -233,11 +227,8 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
|
||||
{
|
||||
char error[BUFSIZ];
|
||||
|
||||
if ( err < 0 ) {
|
||||
sprintf( error, "%ld\n", (long) err );
|
||||
} else {
|
||||
sprintf( error, "%s\n", strerror( err ));
|
||||
}
|
||||
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
|
||||
|
||||
(void)ret->close(ret, 0);
|
||||
return NULL;
|
||||
}
|
||||
@ -251,11 +242,8 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
|
||||
{
|
||||
char error[BUFSIZ];
|
||||
|
||||
if ( err < 0 ) {
|
||||
sprintf( error, "%ld\n", (long) err );
|
||||
} else {
|
||||
sprintf( error, "%s\n", strerror( err ));
|
||||
}
|
||||
sprintf( error, "%s (%d)\n", STRERROR( err ), err );
|
||||
|
||||
(void)ret->close(ret, 0);
|
||||
return NULL;
|
||||
}
|
||||
@ -383,13 +371,9 @@ ldbm_store( LDBM ldbm, Datum key, Datum data, int flags )
|
||||
{
|
||||
char error[BUFSIZ];
|
||||
|
||||
if ( rc < 0 ) {
|
||||
sprintf( error, "%ld\n", (long) rc );
|
||||
} else {
|
||||
sprintf( error, "%s\n", strerror( rc ));
|
||||
}
|
||||
sprintf( error, "%s (%d)\n", STRERROR( rc ), rc );
|
||||
}
|
||||
rc = (-1) * rc;
|
||||
rc = (-1) * rc;
|
||||
|
||||
#elif DB_VERSION_MAJOR >= 2
|
||||
rc = (*ldbm->put)( ldbm, NULL, &key, &data, flags & ~LDBM_SYNC );
|
||||
|
Loading…
Reference in New Issue
Block a user