8619 |
real solution is to check each call to fprintf rather than waiting |
real solution is to check each call to fprintf rather than waiting |
8620 |
until the end like this. */ |
until the end like this. */ |
8621 |
error (1, errno, "error writing to lock file %s", rcs_lockfile); |
error (1, errno, "error writing to lock file %s", rcs_lockfile); |
8622 |
|
|
8623 |
|
/* Flush and sync the file, or the user may be told the commit completed, |
8624 |
|
* while a server crash/power failure could still cause the data to be |
8625 |
|
* lost. |
8626 |
|
* |
8627 |
|
* Invoking rename(",<file>," , "<file>,v") on Linux and almost all UNIXs |
8628 |
|
* only flushes the inode for the target file to disk, it does not |
8629 |
|
* guarantee flush of the kernel buffers allocated for the ,<file>,. |
8630 |
|
* Depending upon the load on the machine, the Linux kernel's flush daemon |
8631 |
|
* process may not flush for a while. In the meantime the CVS transaction |
8632 |
|
* could have been declared committed to the end CVS user (CVS process has |
8633 |
|
* returned the final "OK"). If the machine crashes prior to syncing the |
8634 |
|
* changes to disk, the committed transaction can be lost. |
8635 |
|
*/ |
8636 |
|
if (fflush (fp) != 0) |
8637 |
|
error (1, errno, "error flushing file `%s' to kernel buffers", |
8638 |
|
rcs_lockfile); |
8639 |
|
if (fsync (rcs_lockfd) < 0) |
8640 |
|
error (1, errno, "error fsyncing file `%s'", rcs_lockfile); |
8641 |
|
|
8642 |
if (fclose (fp) == EOF) |
if (fclose (fp) == EOF) |
8643 |
error (1, errno, "error closing lock file %s", rcs_lockfile); |
error (1, errno, "error closing lock file %s", rcs_lockfile); |
8644 |
rcs_lockfd = -1; |
rcs_lockfd = -1; |