Re: [libmicrohttpd] v0.9.53 release date? (w.r.t. websocket race fixes)

2017-03-13 Thread Evgeny Grin
Hello Dom,

I expect last fixes for "Upgraded" sockets to be commented in next two day.
After several days of testing we should make new release.

-- 
Best Wishes,
Evgeny Grin

On 10.03.2017 13:25, Dom F wrote:
> Hello,
> 
> I use the websocket support in libmicrohttpd but it crashes a lot due to
> the races found in v0.9.52.
> 
> I've seen bugs 4844 and 4889 but commit
> 8a84902f7447edd6f677dfa9983c16146dacc7c5 doesn't seem to readily patch
> against v0.9.52.
> 
> So is there a potential release date for a version including fixes for
> the above bugs?
> 
> Thanks,
> 
> Dom
> 



signature.asc
Description: OpenPGP digital signature


Re: [libmicrohttpd] Websockets

2017-03-13 Thread John Duncan
Quick question.  I noticed when I built the library, it didn't move
mhd_sockets.h into the includes.  That file contains all the
MHD_send_/MHD_recv_ macros used in the websockets unit test.  Am I supposed
to re-implement the functions/macros found in there, or am I supposed to
include that code with my project?  I know I could just snip out the code
and use it, but for forward compatibility I'd like to know, from the devs,
how I should proceed for the least number of future-headaches.

~J

On Tue, Mar 7, 2017 at 1:01 PM, Christian Grothoff 
wrote:

> We've not yet updated the tutorial, but maybe the test case helps?
>
> https://gnunet.org/git/libmicrohttpd.git/tree/src/
> microhttpd/test_upgrade.c
>
>
> On 03/03/2017 08:37 PM, John Duncan wrote:
> > I was reading somewhere that websockets have been added to the library?
> If
> > so, is there any example code on how to use them with the library?  I
> have
> > a webserver working so I don't need a full example, just how to upgrade a
> > connection on a callback.
> >
> >
> > Thanks
> >
>
>


Re: [libmicrohttpd] largepost.c reset connection when file already exists

2017-03-13 Thread Christian Grothoff
On 03/11/2017 03:39 PM, Vitaliy T wrote:
> Still there is an issue with re-open a file. Patch applied below to avoid it.

Thanks, Fixed as suggested in 1855c73c..59268ccf.

> Offtopic:
> Are there plans to "say" libmicrohttpd to "clear" network buffers when
> something goes wrong and we are ready to send a response?

The HTTP protocol requires us to read everything at that time (we did
send 100 continue), and so MHD requires you to explicitly toss all the
data. Which is really comparatively cheap, so shouldn't be a big deal.

> Currently, my fears about reading the whole request was confirmed
> (in case of largepost.c the answer_to_connection() function will be
> called as many times as needed).

Yes.  If you want to avoid this, a better method would be to not have
the filename inside the POST upload data (as is done in the example),
but instead in the URL or some other place in the HTTP header.  Then,
you can check upon the *first* call of "answer_to_connection", and
immediately send an error code back if there is a serious problem
detectable at that time.  If the client uses "Expect: 100 continue",
this will avoid the upload of the entire HTTP payload.



signature.asc
Description: OpenPGP digital signature


Re: [libmicrohttpd] Websockets

2017-03-13 Thread Christian Grothoff
On 03/13/2017 09:39 PM, John Duncan wrote:
> Quick question.  I noticed when I built the library, it didn't move
> mhd_sockets.h into the includes.  That file contains all the
> MHD_send_/MHD_recv_ macros used in the websockets unit test.  Am I supposed
> to re-implement the functions/macros found in there, or am I supposed to
> include that code with my project?  I know I could just snip out the code
> and use it, but for forward compatibility I'd like to know, from the devs,
> how I should proceed for the least number of future-headaches.

Those are just convenience wrappers for us around send()/recv(). You are
not expected to use those at all in your own code. The upgrade method
gives you a socket and applications can expect to be able to use the
usual system calls (read/write/send/recv, etc.) directly with the
(web)socket.

Just be aware that you might have been given a socketpair() in case
there's actually HTTPS underneath.  Thus, stuff like ioctl() and
setsockopt() may not work correctly.  If anyone needs support there,
this would have to be added to MHD: This is what MHD_upgrade_action() is
supposed to be used for in the future, in addition to the current
close()-logic.

Happy hacking!

Christian



signature.asc
Description: OpenPGP digital signature


[libmicrohttpd] MHD_get_fdset throws "Illegal instruction" error

2017-03-13 Thread Vitaliy T
Hi,

When I am using EPOLL backend I got the error in the subject:
  Illegal instruction

If I am using MHD_USE_SELECT_INTERNALLY all is OK.

Can you give me a point how to implement an external poller to
run MHD_run(daemon), because I'm using the MHD_USE_SUSPEND_RESUME
flag. And running MHD_run() after resuming a connection is vital.

Do I need to implement my own external epoll-poller from a scratch in this case?
Or may be, I have to use MHD_get_fdset2() with some proper parameters.
Can't figure out where I should dig.

My current program is similar to session.c from doc/examples. There is
MHD_get_fdset() used in main().

Tested on:
1. GNU/Linux, MHD 0.9.50 - 0.9.52 (including).


Thanks!

-- 
With Best Regards,
Vitaliy V. Tokarev