If both modules should be used at the same time, the most problematic point would be
calling `curl_global_init()` several times IMO (although the libcurl documentation states
that it must be called "at least" once). However, **async_http** uses the
`curl_global_init_mem()` version (it allows curl to use kamailio's memory API instead
of the libc one), and if it is called after `curl_global_init()`, it will have no effect.
We chose to bind libcurl with the SHM memory API, because the amount of memory needed to
handle the HTTP requests and responses under heavy load can be huge, and it made more
sense to increase the shared memory pool size than the private ones. The drawback is the
cost of the SHM locking for each operation. Another option could be to allocate a new
dedicated memory pool to each HTTP worker (or a shared one amongst the workers), this is
now easily doable with the new kamailio memory API.
So, in a nutshell, to use both modules at the same time, libcurl initialization should be
done in a shared API that would ensure that the initialization is done only once per
process. To do this, we also have to agree on the memory API used by libcurl. In your
opinion(s), what is the best alternative: libc's malloc, SHM, PKG, dedicated (private
/ shared) pool?
---
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/480#issuecomment-173998873