package milter

  1. Overview
  2. Docs
OCaml libmilter bindings

Install

Dune Dependency

Authors

Maintainers

Sources

1.0.4.tar.gz
sha256=66a3a5cde933e0bf7dbc8e9db622fbcb8313aa8a18a50239773255aa7ac2cfe9
md5=c6e206750966d529ad3bdb0cdc317b50

README.md.html

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;
+       }
+
OCaml

Innovation. Community. Security.