David Bolen wrote:
> 
> > Towards that end, I need to get rsync to cooperate with a perl
> > script.  The perl script may attempt to update a file at the same
> > time that rsync is trying to read from it or write to it.  Since I
> > am the author of the perl script, I am trying to adapt my script to
> > rsync rather than the reverse.
>
> I'm curious about the problem description.  Rsync should only be
> trying to write to a file if it is synchronizing it with some other
> master copy, so if you are saying that might overlap with Perl
> writing, isn't there an underlying risk in your system, since you're
> saying you have two master file copies?  Rsync isn't really that great
> for keeping two files in sync when either can change, at least not
> without some sort of extra control over rsync.

David, you're correct that in my application, both copies may be
changed, and updates must flow in either direction.  My idea (incorrect)
was that when one server gets an update, it immediately invokes rsync
with that individual file as the source, and that rsync could handle
both the lock and the update.

> To your original question though, I'm fairly certain that rsync
> doesn't do any locking at all on its output files.  That's because
> rsync is writing to a temporary file during the transfer, and just
> renames that file on top of the target file as a final step.  In some
> cases it will potentially rename the target file out of the way if it
> seems to be busy (e.g., a running executable on some systems), but
> that's about it.
> 
> You could in theory add your same locking approach to rsync itself 
> (probably in recv_files() in receiver.c) such that it tried 
> to lock the
> target file during the transfer (which would still be to a temporary
> file) and skipped that file if the lock failed.

That makes sense.  Thanks for the explanation and the pointer to
receiver.c/recv_files(); I'll take a look.  In case I find I'm not able
to make it work, do you know of other software that might be worth
looking at for keeping a set of files that might both change
synchronized? You can mail me off-list at [EMAIL PROTECTED], if that would
be more appropriate.

As an aside, that was fast (your response)!

thanks,
-Olaf

Reply via email to