Hi,

I thought I'd mention that Caolan did some experiments [1] with the parser
from node.js. The idea was to get all the parsing done fast in C. I don't
know the it's current status, and it looks like it's written for CHICKEN 4
only.

[1]: https://github.com/caolan/snowy

In my opinion, spiffy is quite fast. Can I ask why you want to use
microhttpd?

K.


On Mon, Mar 25, 2019, 18:17 Peter Bex <pe...@more-magic.net wrote:

> On Mon, Mar 25, 2019 at 03:56:30PM +0100, Massimo Nocentini wrote:
> > Dear list,
> >
> > this is my first message so I take the opportunity to greet everyone.
> >
> > I'm working on a minimal set of bindings [1] for the microhttpd library
> [2]
> > and I'm heading against the following error:
> >
> >    [panic] callback invoked in non-safe context - execution terminated
> >
> > To set the context: the variadic function MHD_start_daemon starts the
> server
> > to accept connection and calls back a Scheme function that provides the
> > content to the client.
>
> Hello Massimo,
>
> From the microhttpd documentation, it seems that it will always start
> a new native thread.  The problem here is that CHICKEN can only run
> inside one native thread and requires complete control of the stack
> within that thread.
>
> When the Scheme callback you passed to MHD_Daemon is called, it is called
> from the thread which microhttpd starts.  It will try to read/write data
> from the nursery (stack) of a different thread, and on GC it will try to
> longjmp back to a stack state in a different thread, which is not going
> to work.  CHICKEN's garbage collector does not play well at all with
> native multithreading.
>
> There might be a way to get it to work but it would require some sort
> of communication between the native threads (all in C), and you'd need to
> set up a green thread in CHICKEN that handles the response somehow.  I
> don't think this is a good approach.  You're probably better off wrapping
> a different library (or just use Spiffy).
>
> Cheers,
> Peter
> _______________________________________________
> Chicken-users mailing list
> Chicken-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users
>
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to