libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] how to make MHD use poll instead of select


From: Evgeny Grin
Subject: Re: [libmicrohttpd] how to make MHD use poll instead of select
Date: Tue, 29 Nov 2016 21:29:51 +0300
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0

On 29.11.2016 13:23, Ken Zangelin wrote:
> Hi,
> 
>     I am unsuccessfully trying to get MHD use poll instead of select.
> 
> According to the documentation, MHD_USE_POLL (64) should do the trick,
> however, I still see only calls to select(), after calling
> MHD_start_daemon like this:
> 
> 
>       int serverMode = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL;
> 
>       mhdDaemon = MHD_start_daemon(serverMode,
>                                    htons(port),
>                                    NULL,
>                                    NULL,
> connectionTreat,                     NULL,
> MHD_OPTION_CONNECTION_MEMORY_LIMIT,  memoryLimit,
> MHD_OPTION_CONNECTION_LIMIT,         maxConns,
> MHD_OPTION_THREAD_POOL_SIZE,         threadPoolSize,
> MHD_OPTION_SOCK_ADDR,                (struct sockaddr*) &sad,
> MHD_OPTION_NOTIFY_COMPLETED,         requestCompleted, NULL,
>                                    MHD_OPTION_END);
> 
MHD_USE_THREAD_PER_CONNECTION do not work with
MHD_OPTION_THREAD_POOL_SIZE. It's stated in documentation, but I'll add
comments to main header.
You don't need to use 'htons' on port number, MHD will do this
automatically.
'connectionTreat' must be a function that generate and queue response.

I could suggest you to start from minimal number of additional parameters.


> I've tried with a few more combinations (depending on the CLI args for
> our server), like:
> 
>     int serverMode = MHD_USE_SELECT_INTERNALLY | MHD_USE_POLL;  //
> MHD_USE_POLL_INTERNALLY
> 
> And also changing poll for epoll:
> 
>     int serverMode = MHD_USE_SELECT_INTERNALLY | MHD_USE_EPOLL_LINUX_ONLY;

That's correct.
New version will have more obvious flag names, like
MHD_USE_INTERNAL_POLLING_THREAD, MHD_USE_POLL_INTERNAL_THREAD and
MHD_USE_EPOLL_INTERNAL_THREAD.
You could try them from official git.

> 
> However, no calls to poll according to strace, just select ...
> 
> I'm on CentOS 6.5 and the version of MHD (not too new), according to
> microhttpd.h, is:
> 
>     /**
>      * Current version of the library.
>      * 0x01093001 = 1.9.30-1.
>      */
>     #define MHD_VERSION 0x00093300
> 
> [ A bit strange btw ... MHD_VERSION says 0.9.33-0 while the comment says
> 1.9.30-1 ... ]
> 
> What am I doing wrong? Why isn't poll used?
It's quite old version, can't really tell what's wrong with such old
version.
Comment just illustrate how to decode version number.

Could you try version from git or 0.9.51 from the official ftp?

-- 
Best Wishes,
Evgeny



reply via email to

[Prev in Thread] Current Thread [Next in Thread]