[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: duplicate delivery with Solaris
> Synopsis: Two (concurrent) router processes work on same message with Solaris
> Zmailer: 2.99.48p6 but probably other versions as well.
> OS: Solaris 2.5 but probably Solaris versions as noted below.
ChangeLog file has:
Fri Feb 14 20:29:25 1997 Matti Aarnio <mea@mea.tmt.tele.fi>
* lib/esyslib.c: erename(), eqrename()
Rewrote eqrename() cleanly in model of Andy Poling's
ideas -- he observed surprising amounts of duplicate
delivery while using rename(2) instead of link(2)/unlink(2)
systemcalls for acquiring a lock on the messages.
And yes, that was about Solaris..
Now how could we write code so that it survives this Solaris feature ?
Perhaps: (And this code is written in email only, not tested on
compiler, nor in any system...)
int
erename(from, to)
char *from, *to;
{
#ifdef HAVE_RENAME
while (rename(from, to) < 0) {
if (errno == EBUSY || errno = EINTR)
continue; /* Sigh, solaris BUSY.. */
fprintf(stderr, "%s: rename(%s,%s): %s\n", progname,
from, to, strerror(errno));
return -1;
}
#else /* !HAVE_RENAME */
redo_unlink:
while (unlink(to) < 0) {
if (errno == ENOENT) break; /* Ok! */
if (errno == EBUSY || errno == EINTR)
continue; /* Sigh, solaris... */
fprintf(stderr, "%s: rename(%s,%s): %s\n", progname,
from, to, strerror(errno));
return -1;
}
while (link(from, to) < 0) {
if (errno == EEXIST)
goto redo_unlink;
if (errno == EBUSY || errno == EINTR)
continue; /* Sigh, Solaris */
fprintf(stderr, "%s: rename(%s,%s): %s\n", progname,
from, to, strerror(errno));
return -1;
}
while (unlink(from) < 0) {
if (errno == ENOENT) break;
if (errno == EBUSY) continue; /* Sigh, Solaris */
fprintf(stderr, "%s: rename(%s,%s): %s\n", progname,
from, to, strerror(errno));
while (unlink(to) < 0) {
if (errno == ENOENT) break;
}
return -1;
}
#endif /* !HAVE_RENAME */
return 0;
}
(and likewise for eqrename() )
....
> Peter Ip/Michael Simms/Alex Nishri
> Network Services
> University of Toronto
/Matti Aarnio <mea@nic.funet.fi>