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

The php accelerator module calls flush incorrectly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.7
    • Fix Version/s: 0.7
    • Component/s: PHP - Library
    • Labels:
    • Patch Info:
      Patch Available

      Description

      The php accelerator module calls flush on the transport when its internal buffer is full. However it should only write its internal buffer to the transport and flush to the transport when flush is explicitly called.

      I ran into this problem because I am using thrift to send data from php to java using a THsHaServer in java which requires the use of a TFramedTransport. As a result of this incorrect behavior, partial messages where sent to the THsHaServer and it couldn't handle them.

      The php extension has an internal buffer of some size (8K by default). When this internal buffer fills up the extension would write its buffer to the transport and call flush on the transport. So messages that are greater than 8K would be broken up and sent it different frames to the THsHAServer causing errors.

      The correct behavior is for the php extension to just call write on its transport when its internal buffer is full and then to call flush once the message is complete. I have submitted a patch that fixes this bug. I created a new protected method on the PHPOutputTransport called internalFlush that just writes the internal buffer to the transport. This way flush is only called when a message is complete and the internal buffer can get flushed to the PHP transport object when it is full.

        Attachments

        1. thrift-1228.patch
          0.9 kB
          Nathaniel Cook

          Activity

            People

            • Assignee:
              nvcook42 Nathaniel Cook
              Reporter:
              nvcook42 Nathaniel Cook
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: