Mailing List Archive

_step question II: where example code is wrong
Hi Alvaro,


I have implemented you 'generic' code into my handler.

ret_t
cherokee_handler_example_step (cherokee_handler_example_t *hdl,
cherokee_buffer_t *buf)
{
if (cherokee_buffer_is_empty (&hdl->prebuilt))
return ret_eof;

cherokee_buffer_add (buf, &hdl->prebuilt, 1024);
cherokee_buffer_move_to_begin (&hdl->prebuilt, 1024);

if (cherokee_buffer_is_empty (&hdl->prebuilt))
return ret_eof_have_data;

return ret_ok;
}



Now cherokee_buffer_add seems to be wrongly used, we all don't know what
type prebuilt is, but I think we can assume it is a cherokee_buffer_t, so
one would wonder...

What do you mean here?

Do you want to:

cherokee_buffer_add (buf, hdl->prebuilt.buf, 1024);


What the alternative was to use add_buffer, but that probably adds the
entire buffer.


Currently I'm doing the following thing, I generate an RRD 'png' image. In
to a filename:

cherokee_buffer_read_file(&hdl->prebuilt, filename);


But the behavior I see, if I start hitting F5 on my handler, *sometimes*
instead of serving me a nice PNG. It will return a headerless binary
transmission.

When I look at the dump I see a very strange binary prefix before
HTTP/1.1, as if buffers get too big or looping. I'll try some valgrinding.
But maybe someone has some hints.


Stefan
_step question II: where example code is wrong [ In reply to ]
On 11 Aug 2008, at 20:46, Stefan de Konink wrote:

> What do you mean here?
> Do you want to:
>
> cherokee_buffer_add (buf, hdl->prebuilt.buf, 1024);
>
> What the alternative was to use add_buffer, but that probably adds the
> entire buffer.

Yep, good catch.. I wanted to say hdl->prebuilt.buf, actually.

> But the behavior I see, if I start hitting F5 on my handler,
> *sometimes*
> instead of serving me a nice PNG. It will return a headerless binary
> transmission.

It could be because a buffer remains dirty for some reason.. and it
has more information (trash) than what you suppose it has. I guess
this is the most likely reason, actually.

It could also be because a wrong file descriptor. Again, if for some
reason you read from an old fd that was supposed to be reopened you
could be the wrong information.

> When I look at the dump I see a very strange binary prefix before
> HTTP/1.1, as if buffers get too big or looping. I'll try some
> valgrinding.
> But maybe someone has some hints.

Yes, valgrind may point it out. If not, try attaching the debugger and
printing the buffer, or even better, display it while you trace the
handler methods: display *buffer

Good luck Stefan!

--
Greetings, alo.
http://www.alobbs.com/