Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

libmilter: howto cleanup on thread termination

16 views
Skip to first unread message

Ralf Soergel

unread,
Jun 9, 2017, 6:35:45 PM6/9/17
to
Hi there,
in a milter I have to cleanup some things if and only if a thread
terminates.

Milter doc: "N connections mapped onto M threads, M <= N".
Because of this IMO the xxfi_close() callback is not mandatory the
end
of life of a thread.

Is there a callback on thread termination?

Thanks in advance for a hint.

Kind regards
Ralf


--
Linux is like a wigwam: no Windows, no Gates, Apache inside

Claus Aßmann

unread,
Jun 11, 2017, 9:14:06 AM6/11/17
to
Ralf Soergel wrote:

> in a milter I have to cleanup some things if and only if a thread
> terminates.

Can you be more specific?
What did you allocate and where?
What do you need to "clean up"?

> Is there a callback on thread termination?

AFAICT the docs don't list one.

--
Note: please read the netiquette before posting. I will almost never
reply to top-postings which include a full copy of the previous
article(s) at the end because it's annoying, shows that the poster
is too lazy to trim his article, and it's wasting the time of all readers.

Ralf Soergel

unread,
Jun 23, 2017, 6:55:31 PM6/23/17
to
Claus Aßmann
<ca+sendmail(-no-copies-please)@mine.informatik.uni-kiel.de> at
Sun,
11 Jun 2017 13:14:05 +0000 (UTC) writes:

>> in a milter I have to cleanup some things if and only if a
>> thread terminates. > > What did you allocate and where?

I use libcrypto API of the openssl package in a milter, handling
S/MIME messages. These libcrypto functions malloc() data per
thread,
e. g. the error message queue of a thread if the first error in
thread
is recorded.

Threads will started by libmilter. After they died, this data
remains
as memory leak. But I will free() the data.

I think, I've now found a solution, using thread specific data.
In pthread_key_create() can set up a destructor function.
This destructor is calling on thread exit. See

https://linux.die.net/man/3/pthread_key_create
and
https://linux.die.net/man/3/pthread_setspecific
0 new messages