libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Setting microhttpd thread names


From: Christian Grothoff
Subject: Re: [libmicrohttpd] Setting microhttpd thread names
Date: Wed, 29 Apr 2015 09:42:16 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0

On 04/29/2015 02:12 AM, Denis Dowling wrote:
> Hi All,
> 
>  
> 
> I am using libmicrohttpd in a multithreaded application. There are
> threads that libmicrohttpd starts, some worker threads and some output
> threads that block in disk writes.  When debugging an application like
> this I find it is useful to set names on each of the threads using the
> pthread_setname_np call. Libmicrohttpd sets all of its thread names to
> “libmicrohttpd”. I am using select dispatching so there is only one
> libmicrohttpd thread but given the thread handle is not exposed through
> the API I have no way of easily changing the thread names.

Well, once you're called, you can do pthread_self() to get the thread
handle.
Until you're called, how would you even expect MHD to tell you the
differences between the threads? #1 and #2? Without the context of a
connection, they're all pretty much the same to you, so all you can do
is number them -- and given that you have the pointer (which is a
number), adding a number is not very useful IMO.


> I have a hack working at the moment that sets the thread name in the
> access handler callback but this only get performed after a request have
> arrived.

Not sure that's a hack, sounds like the only (moderately) useful thing
to do here. As I said: without a request, what basis would you have for
naming the thread?

> Anyone know a clean way to do this?

I don't quite see the problem with this approach.  (But also, what would
you even want to set the thread name to, without any context? How is
your name going to be more meaningful than "libmicrohttpd"?  I guess if
you run a dozen MHD-daemons in one process (i.e. on different ports),
one might like more diverse names, but I'm not sure that case is common
enough to justify an extended API -- especially since the names are
really just a minor debugging aid).

> If not is there any
> interest in some patches to add an API to set the thread names or get
> access to the libmicrohttpd thread handles?

Not really, that's really just bloating the API IMO. I already found
setting the thread names to "libmicrohttpd" was a bit of bloat.  ;-)

Happy hacking!

Christian

Attachment: 0xE29FC3CC.asc
Description: application/pgp-keys


reply via email to

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