[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [leafnode-list] Reproducibly truncate groupinfo
Matthias Andree wrote:
> I slightly modified writeactive and caught these:
>
> Jun 13 11:16:47 emma1 leafnode[15058]: cannot open new groupinfo file: \
> file already exists
Yuck. This should have caught by the locking mechanism.
Would it be a good idea to modify your additional code as follows to
avoid the problem of concurrent processes writing to the groupinfo file?
> int fd;
>
> strcpy(s, spooldir);
> strcat(s, "/leaf.node/groupinfo.new");
while ((fd = open(s, O_WRONLY | O_CREAT | O_EXCL, 0600)) < 0) {
if (errno != EEXIST) {
> syslog(LOG_ERR, "cannot open new groupinfo file: %m");
> return;
}
sleep(1);
> }
>
> a = fdopen( fd, "w" );
> if ( !a ) {
> syslog( LOG_ERR, "cannot fdopen new groupinfo file: %m" );
> return;
> }
(Obviously, this does not tackle the source of the problem, i.e. the
buggy file locking.)
--Cornelius.
--
/* Cornelius Krasel, U Wuerzburg, Dept. of Pharmacology, Versbacher Str. 9 */
/* D-97078 Wuerzburg, Germany email: krasel@xxxxxxxxxxxxxxxxxxxxxxxxxxxx */
/* "Science is the game we play with God to find out what His rules are." */
--
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list