[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] 5 bytes missing from starts of input buffer


After a bit of investigation I seem to have fixed the issue. In my original code I had...


After removing the second statement the problem doesn't reoccur.

On 5 September 2013 16:18, Mark Delany <z4c@xxxxxxxxxxxxx> wrote:
> I have a strange problem where every so often my server socket input
> buffer does not contain the first 5 bytes as expected.

> Strange! My first suggestion for debugging this would be to try to
> come up with a stripped-down minimal toy demo

I presume you've determined that your code is actually reading those 5
bytes somewhere. Have you got debug around all your read/recv calls?

It that's hard - perhaps because you're using 3rd-party libraries -
consider using ktrace/strace to confirm that the missing 5 bytes are
actually being consumed by a read()/recv() call.

Also, are you doing the reads yourself or are you using bufferevents?
A little more info about how your using libevent might be
useful. Threads?

A not uncommon bug I've seen is when an fd is copied by some code and
then used later. In the mean time some underlying set of events have
closed and opened the same fd - thus the "copy fd" code is now reading
an fd it shouldn't be. ktrace/strace might give you clues on this too.

To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.