HADOOP-11403. Avoid using sys_errlist on Solaris, which lacks support for it (Malcolm Kavalsky via Colin P. McCabe)

This commit is contained in:
Colin Patrick Mccabe 2015-01-29 15:43:57 -08:00
parent 30a8778c63
commit e36ef3b402
4 changed files with 13 additions and 14 deletions

View File

@ -794,6 +794,9 @@ Release 2.7.0 - UNRELEASED
HADOOP-9907. Webapp http://hostname:port/metrics link is not working. HADOOP-9907. Webapp http://hostname:port/metrics link is not working.
(aajisaka) (aajisaka)
HADOOP-11403. Avoid using sys_errlist on Solaris, which lacks support for it
(Malcolm Kavalsky via Colin P. McCabe)
Release 2.6.1 - UNRELEASED Release 2.6.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -110,9 +110,15 @@ jthrowable newIOException(JNIEnv* env, const char *fmt, ...)
const char* terror(int errnum) const char* terror(int errnum)
{ {
#if defined(__sun)
// MT-Safe under Solaris which doesn't support sys_errlist/sys_nerr
return strerror(errnum);
#else
if ((errnum < 0) || (errnum >= sys_nerr)) { if ((errnum < 0) || (errnum >= sys_nerr)) {
return "unknown error."; return "unknown error.";
} }
return sys_errlist[errnum]; return sys_errlist[errnum];
#endif
} }

View File

@ -19,6 +19,7 @@
#include "org_apache_hadoop.h" #include "org_apache_hadoop.h"
#include "org_apache_hadoop_io_nativeio_NativeIO.h" #include "org_apache_hadoop_io_nativeio_NativeIO.h"
#include "org_apache_hadoop_io_nativeio_NativeIO_POSIX.h" #include "org_apache_hadoop_io_nativeio_NativeIO_POSIX.h"
#include "exception.h"
#ifdef UNIX #ifdef UNIX
#include <assert.h> #include <assert.h>
@ -893,11 +894,7 @@ void throw_ioe(JNIEnv* env, int errnum)
char message[80]; char message[80];
jstring jstr_message; jstring jstr_message;
if ((errnum >= 0) && (errnum < sys_nerr)) { snprintf(message,sizeof(message),"%s",terror(errnum));
snprintf(message, sizeof(message), "%s", sys_errlist[errnum]);
} else {
snprintf(message, sizeof(message), "Unknown error %d", errnum);
}
jobject errno_obj = errno_to_enum(env, errnum); jobject errno_obj = errno_to_enum(env, errnum);

View File

@ -21,21 +21,14 @@
#include <curl/curl.h> #include <curl/curl.h>
#include "hdfs_http_client.h" #include "hdfs_http_client.h"
#include "exception.h"
static pthread_mutex_t curlInitMutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t curlInitMutex = PTHREAD_MUTEX_INITIALIZER;
static volatile int curlGlobalInited = 0; static volatile int curlGlobalInited = 0;
const char *hdfs_strerror(int errnoval) const char *hdfs_strerror(int errnoval)
{ {
const char *msg = NULL; return terror(errnoval);
if (errnoval < 0 || errnoval >= sys_nerr) {
msg = "Invalid Error Code";
} else if (sys_errlist == NULL) {
msg = "Unknown Error";
} else {
msg = sys_errlist[errnoval];
}
return msg;
} }
int initResponseBuffer(struct ResponseBuffer **buffer) int initResponseBuffer(struct ResponseBuffer **buffer)