[Exim] Cygwin port: two small requests

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Pierre A. Humblet
Datum:  
To: exim-users
Betreff: [Exim] Cygwin port: two small requests
I am porting Exim to Cygwin, a Unix layer emulation running
on top of Windows on ordinary PCs and have two issues

1)
Cygwin's implementation of byte-range locking with fcntl()
relies on Microsoft LockFileEx(), which implements a mandatory
record locking scheme instead of an advisory scheme as in Unix.
This means that if a process has locked a file, another process
may not get access while doing a read(), in addition to
when doing an fcntl().

Most of the time the difference does not matter. However
this poses a problem e.g. for local deliveries because
deliver_message() opens and write-locks the deliver_datafile
before forking a subprocess which reads (but does not lock,
as it would fail) the deliver_datafile (in appendfile.c).
With the Microsoft scheme, the read() fails.

There is a simple solution: the subprocess does an lseek()
to skip the first DATA_START_OFFSET bytes. Thus the desired
locking effect can be obtained by locking ONLY the first
DATA_START_OFFSET bytes, while not hindering the read().
Concretely line 74 of spool_in.c,

lock_data.l_whence = lock_data.l_start = lock_data.l_len = 0;

can be replaced by

lock_data.l_type = F_WRLCK;    /* Only lock the first line */
lock_data.l_whence = SEEK_SET;
lock_data.l_start = 0;
lock_data.l_len = DATA_START_OFFSET;


I don't think this has any negative consequences.

2)
When a file is opened with fopen(..., "r" or "w") on a Windows
machine, an extra CR may be added/removed at end of lines.
Standard C allows to add a "b" to the mode string ("rb" or "wb")
to avoid these effects. The "b" has no effect on standard Unix
systems. Could you add it in all Exim files?
The attached script, AddB.sh will
- identify all .c files containing fopen() (in the current directory)
- rename them by adding an ".org" suffix
- recreate the .c file, adding the b where needed.
- run diff to verify the changes

Thanks Philip.

Pierre

P.S.:1) There is a similar issue with open(). os.c-cygwin handles it.
     2) With those changes + native gdbm, I have Exim running under Win98.
        Assuming no bad surprises, this might greatly increase the number
        of Exim users.