package milter
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=66a3a5cde933e0bf7dbc8e9db622fbcb8313aa8a18a50239773255aa7ac2cfe9
md5=c6e206750966d529ad3bdb0cdc317b50
Description
This package provides OCaml bindings for sendmail's libmilter, allowing integration of OCaml programs with compatible MTAs.
Published: 02 Mar 2018
README
OCaml-Milter
Introduction
This library provides OCaml bindings to libmilter.
Build and installation
OCaml-Milter can be installed via opam.
$ opam install milter
Limitations
Since libmilter uses pthreads internally, this module is thread-safe. However, due to the current OCaml implementation, each of the milter callbacks must acquire a global runtime lock while being executed, meaning that effectively only a single thread will be running at a given time.
One interesting possibility is to patch libmilter so that it sets the SO_REUSEPORT
socket option, which allows you to spawn multiple milter procecess listening on the same address and port, with kernel-provided load-balancing.
In the sendmail source, you can add the following code in libmilter/listener.c
, right after the point where SO_REUSEADDR
is set.
+ sockopt = 1;
+ if (
+#if NETUNIX
+ addr.sa.sa_family != AF_UNIX &&
+#endif /* NETUNIX */
+ setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (void *) &sockopt,
+ sizeof(sockopt)) == -1)
+ {
+ smi_log(SMI_LOG_ERR,
+ "%s: set reuseport failed (%s)", name,
+ sm_errstring(errno));
+ (void) closesocket(sock);
+ return INVALID_SOCKET;
+ }
+