-- trying to make TFileTransport destructor quicker

Summary:
- setFlushMaxTimeUs to a lower value before trying to close the file

Reviewed By: jwang


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665095 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/transport/TFileTransport.cpp b/lib/cpp/src/transport/TFileTransport.cpp
index 5fb9ef3..aafdc21 100644
--- a/lib/cpp/src/transport/TFileTransport.cpp
+++ b/lib/cpp/src/transport/TFileTransport.cpp
@@ -114,6 +114,9 @@
 TFileTransport::~TFileTransport() {
   // flush the buffer if a writer thread is active
   if (writerThreadId_ > 0) {
+    // reduce the flush timeout so that closing is quicker
+    setFlushMaxUs(300*1000);
+
     // flush output buffer
     flush();
 
@@ -296,13 +299,15 @@
 
   while(1) {
     // this will only be true when the destructor is being invoked
-    if(closing_) {
+    if(closing_) {      
       // empty out both the buffers
       if (enqueueBuffer_->isEmpty() && dequeueBuffer_->isEmpty()) {
         if(-1 == ::close(fd_)) {
           perror("TFileTransport: error in close");
           throw TTransportException("TFileTransport: error in file close");
         }
+        // just be safe and sync to disk
+        fsync(fd_);
         fd_ = 0;
         pthread_exit(NULL);
         return;