Thrift: Better handling of strerror_r.

Summary:
Someone thought it would be a good idea to have two different signatures
for strerror_r, with subtly different semantics (strlcpy = smart).
We now work properly with either of them.

Also fixed a test to work on 32-bit, you sloppy <expletive>s.

Reviewed By: mcslee

Test Plan:
Rebuild thrift.
Force one of these errors to be thrown.

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665215 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/transport/TServerSocket.cpp b/lib/cpp/src/transport/TServerSocket.cpp
index ade0fd4..9182da7 100644
--- a/lib/cpp/src/transport/TServerSocket.cpp
+++ b/lib/cpp/src/transport/TServerSocket.cpp
@@ -239,25 +239,22 @@
                               (socklen_t *) &size);
     
   if (clientSocket < 0) {
+    int errno_copy = errno;
     GlobalOutput("TServerSocket::accept()");
-    char b_error[1024];
-    strerror_r(errno, b_error, sizeof(b_error));
-    throw TTransportException(TTransportException::UNKNOWN, string("ERROR:") + b_error);
+    throw TTransportException(TTransportException::UNKNOWN, "accept()", errno_copy);
   }
 
   // Make sure client socket is blocking
   int flags = fcntl(clientSocket, F_GETFL, 0);
   if (flags == -1) {
+    int errno_copy = errno;
     GlobalOutput("TServerSocket::select() fcntl GETFL");
-    char b_error[1024];
-    strerror_r(errno, b_error, sizeof(b_error));
-    throw TTransportException(TTransportException::UNKNOWN, string("ERROR:") + b_error);
+    throw TTransportException(TTransportException::UNKNOWN, "fcntl(F_GETFL)", errno_copy);
   }
   if (-1 == fcntl(clientSocket, F_SETFL, flags & ~O_NONBLOCK)) {
+    int errno_copy = errno;
     GlobalOutput("TServerSocket::select() fcntl SETFL");
-    char b_error[1024];
-    strerror_r(errno, b_error, sizeof(b_error));
-    throw TTransportException(TTransportException::UNKNOWN, string("ERROR:") + b_error);
+    throw TTransportException(TTransportException::UNKNOWN, "fcntl(F_SETFL)", errno_copy);
   }
   
   shared_ptr<TSocket> client(new TSocket(clientSocket));