lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, Oct 12, 2011 at 10:16, Sam Roberts <> wrote:
> On Tue, Oct 11, 2011 at 10:36 PM, HyperHacker <> wrote:
>> I can't seem to reproduce the missing-last-bytes issue except in my
>> server, which is rather large and complex for a testcase and is using
>> threading and the acceptfd patch. (I did test acceptfd in a smaller
>> script as well.) Who knows why that's happening.
> What's the acceptfd patch?
> Instrument the code with some cutting edge technology, printf, in the
> buffer sections to allow you to see what's happening, if you want to
> track this down. Make sure your threads aren't eating each other's
> data, and its not the CR/LFs that you are missing.
> Cheers,
> Sam

Well I've got bit by this issue again, and so I went ahead and dug
into the code.

Now, the LuaSocket manual says: "Also, after the error message, the
function returns the partial result of the transmission." I took this
to mean:
result, error, partial_result = sock:receive()

Now am I crazy, or are there cases where "after the error message"
actually means "appended to the error message string", e.g. you get an
error like "timeout some_partial_string"? Because that didn't make
much sense to me, but I could have sworn I saw it doing that and
relied on this behaviour and it worked...

It looks like it is indeed returning the partial results after (as in,
next in the return list) the error message. It's also interesting to
note that if you do print(sock:receive(9999)), the string 'timeout' is
exactly long enough to be separated from the following string by only
one space, giving the impression that it's one long string. But still
I could swear I actually did this, splitting the error message at the
first space, and found my data there...

Maybe too much cola has just rotted my brain...

Sent from my toaster.