Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4591

lua client uses two write() calls per framed message send

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.11.0
    • Fix Version/s: 0.12.0
    • Component/s: Lua - Library
    • Labels:
      None
    • Flags:
      Important

      Description

      1) realize thrift server with TNonblockingServer via c++;

      2) realize thrift client via lua lib and choose frame transport.

      3) call remote interface failed with "TTransportException:0: Default (unknown)" print, and the server show "TConnection::workSocket(): THRIFT_EAGAIN (unavailable resources)" error.

      4)investigate this fault with tcpdump tool, attachment 9090.pcap show the frame msg doesnot contains frame size field, the rifht situation of attachment 9090_1.pcap show the frame msg contains 4 bytes (00 00 00 25) before protocol id field.

      5) dig into the fault and tried to find root cause, then i found there is an fault in TFramedTransport:flush function in TFramedTransport.lua file. the original realization is:


      function TFramedTransport:flush()
        if self.doWrite == false then
          return self.trans:flush()
        end

        – 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


      which send frame size file and reset msg content independently.

        Attachments

        1. 9090.pcap
          0.9 kB
          allen_lee
        2. 9090_1.pcap
          0.8 kB
          allen_lee

          Issue Links

            Activity

              People

              • Assignee:
                jking3 James E. King III
                Reporter:
                allen_lee allen_lee
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 4h
                  4h
                  Remaining:
                  Remaining Estimate - 4h
                  4h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified