You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2015/06/14 20:57:04 UTC

thrift git commit: THRIFT-3180 fix framed transport

Repository: thrift
Updated Branches:
  refs/heads/master 9b3b8d498 -> 9815c19d7


THRIFT-3180 fix framed transport

This closes #515


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/9815c19d
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/9815c19d
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/9815c19d

Branch: refs/heads/master
Commit: 9815c19d7ea39b8585c2848b523e7182bb26b4c7
Parents: 9b3b8d4
Author: zzn <zi...@gmail.com>
Authored: Thu Jun 4 19:05:55 2015 +0800
Committer: Roger Meier <ro...@apache.org>
Committed: Sun Jun 14 20:50:03 2015 +0200

----------------------------------------------------------------------
 lib/lua/TFramedTransport.lua | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/9815c19d/lib/lua/TFramedTransport.lua
----------------------------------------------------------------------
diff --git a/lib/lua/TFramedTransport.lua b/lib/lua/TFramedTransport.lua
index 84ae3ec..437b701 100644
--- a/lib/lua/TFramedTransport.lua
+++ b/lib/lua/TFramedTransport.lua
@@ -38,7 +38,7 @@ function TFramedTransport:new(obj)
     error('You must provide ' .. ttype(self) .. ' with a trans')
   end
 
-  return TTransportBase:new(obj)
+  return TTransportBase.new(self, obj)
 end
 
 function TFramedTransport:isOpen()
@@ -69,7 +69,7 @@ function TFramedTransport:read(len)
   end
 
   local val = string.sub(self.rBuf, 0, len)
-  self.rBuf = string.sub(self.rBuf, len)
+  self.rBuf = string.sub(self.rBuf, len+1)
   return val
 end
 
@@ -79,9 +79,6 @@ function TFramedTransport:__readFrame()
   self.rBuf = self.trans:readAll(frame_len)
 end
 
-function TFramedTransport:readAll(len)
-  return self.trans:readAll(len)
-end
 
 function TFramedTransport:write(buf, len)
   if self.doWrite == false then
@@ -91,7 +88,7 @@ function TFramedTransport:write(buf, len)
   if len and len < string.len(buf) then
     buf = string.sub(buf, 0, len)
   end
-  self.wBuf = self.wBuf + buf
+  self.wBuf = self.wBuf .. buf
 end
 
 function TFramedTransport:flush()
@@ -102,6 +99,8 @@ function TFramedTransport:flush()
   -- If the write fails we still want wBuf to be clear
   local tmp = self.wBuf
   self.wBuf = ''
+  local frame_len_buf = libluabpack.bpack("i", string.len(tmp))
+  self.trans:write(frame_len_buf)
   self.trans:write(tmp)
   self.trans:flush()
 end