THRIFT-2027: Minor 64-bit and NOMINMAX issues in C++ library
authorBen Craig <bencraig@apache.org>
Wed, 9 Oct 2013 20:21:38 +0000 (15:21 -0500)
committerBen Craig <bencraig@apache.org>
Wed, 9 Oct 2013 20:21:38 +0000 (15:21 -0500)
Client: cpp
Patch: Ben Craig

lib/cpp/src/thrift/server/TNonblockingServer.cpp
lib/cpp/src/thrift/transport/THttpServer.cpp
lib/cpp/src/thrift/transport/TZlibTransport.cpp

index b9553c4..1552e89 100644 (file)
@@ -893,7 +893,7 @@ TNonblockingServer::TConnection* TNonblockingServer::createConnection(
   // pick an IO thread to handle this connection -- currently round robin
   assert(nextIOThread_ < ioThreads_.size());
   int selectedThreadIdx = nextIOThread_;
-  nextIOThread_ = (nextIOThread_ + 1) % ioThreads_.size();
+  nextIOThread_ = static_cast<uint32_t>((nextIOThread_ + 1) % ioThreads_.size());
 
   TNonblockingIOThread* ioThread = ioThreads_[selectedThreadIdx].get();
 
@@ -1421,7 +1421,7 @@ void TNonblockingIOThread::notifyHandler(evutil_socket_t fd, short which, void*
   while (true) {
     TNonblockingServer::TConnection* connection = 0;
     const int kSize = sizeof(connection);
-    int nBytes = recv(fd, cast_sockopt(&connection), kSize, 0);
+    long nBytes = recv(fd, cast_sockopt(&connection), kSize, 0);
     if (nBytes == kSize) {
       if (connection == NULL) {
         // this is the command to stop our thread, exit the handler!
index 1135270..e5b3327 100644 (file)
@@ -92,7 +92,7 @@ bool THttpServer::parseStatusLine(char* status) {
     string header = h.str();
 
     // Write the header, then the data, then flush
-    transport_->write((const uint8_t*)header.c_str(), header.size());
+    transport_->write((const uint8_t*)header.c_str(), static_cast<uint32_t>(header.size()));
     transport_->write(buf, len);
     transport_->flush();
 
index d77eedd..cdde7c3 100644 (file)
@@ -143,7 +143,7 @@ uint32_t TZlibTransport::read(uint8_t* buf, uint32_t len) {
   while (true) {
     // Copy out whatever we have available, then give them the min of
     // what we have and what they want, then advance indices.
-    int give = std::min((uint32_t) readAvail(), need);
+    int give = (std::min)((uint32_t) readAvail(), need);
     memcpy(buf, urbuf_ + urpos_, give);
     need -= give;
     buf += give;