nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

NOTES-mxfr.md (2235B)


      1 
      2 # MXF-Remote Notes
      3 
      4 ## A word on memory management and hash tables
      5 
      6 One of the structures we use in MXF Remote Connector is a UTHash hash table. UTHash does its own memory management and doesn't use strallocs like the rest of the program does. There will thus be two kinds of strong pointers into the heap in MXF-Remote - stralloc/genalloc from skalibs (and typealloc, which is gen_alloc from Notqmail - this is the same type of thing), and entries in UTHashes.
      7 
      8 We use UTHash to store information about skadns queries we make, and about fds which we select for readability (I hope that we will only ever select skadns fds for readability; client apps communicate with us the same way qmail-remote communicates with qmail-rspawn). With this, once the skadns fd raises readable, we needn't iterate over a costly array datum - we can just ask the fd hash for the fd and in nearly-constant time know that that's the skadns fd, and then ask the query hash for the query ID and in nearly-constant time get a weak pointer to the protocol that it's referring to (the strong pointer being somewhere on genalloc protocols).
      9 
     10 It's also conceivable that we stub out constmap and use UTHash for that (control/<srvservice>routes - static routing for protocols) too.
     11 
     12 ### Notes in mxf-remote.c (MXF Remote Connector)
     13 
     14 ## Globals
     15 
     16 Global variables, save for buffer_2_, start with a Capital Letter. Typedefs always end with _t.
     17 
     18 ## Data structures
     19 
     20 protocol_t is a typedef struct containing a bunch of fields. They are NOT documented here.
     21 
     22 ### A word on protocol_t
     23 
     24 This struct has grown to accomodate dynamically allocated pointers to DNS (SRV, MX, AAAA and A) results. A stralloc pointer to mxresult_t[] in each protocol gets sorted using qsort once DNS is done.
     25 
     26 ## A word on type management with genallocs.
     27 
     28 genallocs are just strallocs, and they don't contain any type information. Because of this, they are wholly unsuitable for the purpose at hand. They are only used here in interactions with skadns, the DNS resolver.
     29 
     30 ## mxf-remote.c:0010 - Address mangling
     31 
     32 Of note here is that we leave address mangling to the client program. We do not have an addrmangle function (although one will be available, surgically taken from qmail-remote.c).