Bojan Smojver wrote:
>
>> Socket cleanup is private, so
>> cannot modify that.
>
> When you create your socket with apr_socket_create(), there is a pool
> argument there. If you hang a cleanup off it, it will run before close()
> in socket_cleanup().
What do you mean by "hang a cleanup off it"?
Socket cleanup is private function and cannot be modified.
constructor(res, pool) {
res->sock = socket_create(pool)
}
destructor(res) {
socket_shutdown(res->sock);
socket_close(res->sock);
}
Now this might core because socket_create always registers
a cleanup that will call socket_close before destructor, so
my calls in destructor will be touching closed socket.
What I can do is:
my_cleanup(res)
{
socket_shutdown(res->sock);
socket_close(res->sock);
res->sock = NULL
}
constructor(res, pool) {
res->sock = socket_create(pool)
res->subpool = pool_create(pool)
cleanup_register(res, res->subpool, my_cleanup);
}
destructor(res) {
if (res->sock) {
pool_cleanup_run(res->subpool, my_cleanup)
}
}
So the whole bunch of code, two additional pools for each object
(16K of wasted memory; multiply that by 1000 sockets), for what?
A simple cleanup. I really don't understand the opposition
for doing a things in a clean and safe way :(.
Regards
--
^(TM)