OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: A question about Milters and Thread Safety

From: Ronald F. Guilmette (rfgmonkeys.com)
Date: Tue Sep 04 2007 - 12:47:34 CDT


In message <46DC7A95.8040503msgid.tls.msk.ru>,
Michael Tokarev <mjttls.msk.ru> wrote:

>Ronald F. Guilmette wrote:
>> In message <20070903193047.4AF311F3EA1spike.porcupine.org>,
>> wietseporcupine.org (Wietse Venema) wrote:
>[]
>>> Your milter application runs on top of libmilter.
>>
>> Well, that sort-of begs the question... What if it _didn't_ run on
>> top of libmilter? What if it skipped that and tried to interface
>> to Postfix smtpd directly? Would my milter still have to be
>> thread-safe under that scenario?
>
>Your app can implement/talk milter protocol internally. You don't
>interface to Postfix smtpd directly, but you use sockets to talk
>to Postfix. Speaking of the protocol - well, one (reference)
>implementation of server-side milter (Postfix is on client side
>in this case) is libmilter, which use threads - you can roll your
>own...

Thanks. That's exactly what I suspected... and I may indeed have to do
that.

>> (Please forgive me for making such an issue of this, but it really
>> would be a major pain in the ass to make what I have in mind thread-
>> safe. A significant part of the problem with doing that... but
>> certainly not the only problem... is that the spam filter that I'd
>> like to turn into a milter does DNS lookups. Sadly, I am not aware
>> of any thread-safe DNS primitives library, so I kind-of think that
>> I'd be stuck trying to write my own, from scratch. Am I just looking
>> in the Wrong Places? Does anybody here happen to know of a reasonably
>> priced thread-safe DNS primitives library?)
>
>Ever looked at my udns -- http://www.corpit.ru/mjt/udns.html ?

Funny you should mention that! I was looking at that just yesterday.

That _may_ be the solution to my problem, but just as a general matter,
I would greatly prefer not to have to worry about thread safety at all
if I can avoid it. Also, programming in an event driven style is likely
to be a good deal harder than just making simple calls to res_query()...
as my filter does now... and then just waiting, synchronously, for the
result to come back.

Regards,
rfg