libmicrohttpd
[Top][All Lists]
Advanced

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

[libmicrohttpd] Sharing per-thread resources between connections


From: Carlos Eduardo Moreira dos Santos
Subject: [libmicrohttpd] Sharing per-thread resources between connections
Date: Tue, 1 Jul 2014 01:30:07 +0900

Hi,

I'm using zeromq between a request and a response. Its socket is not thread-safe and that's one of the reasons I chose MHD_USE_SELECT_INTERNALLY. As I am also using a thread pool, I have different sockets for each thread. It is expensive to open and close a socket in every connection and I would like to share a socket between all same-thread connections. I didn't find a way to do it, so I made a small change in the code in order to get the thread number (starting from 0) from the connection daemon. Thus, I can initialize an array of sockets only once (in the main function) and have them indexed by the thread number to be accessed later.

As a side effect, I have to include internal.h, but it is working as expected. Was there a better way of doing this that I haven't noticed?

Regards,
Carlos Eduardo

reply via email to

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