Author: adrian.chadd
Date: Thu Jul 9 21:17:20 2009
New Revision: 14172
Modified:
playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_build_dir.c
playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_build_log.c
Log:
Fix up the helper to die on write() failure. This should make the helper
die gracefully if Lusca goes away during a rebuild.
Modified: playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_build_dir.c
==============================================================================
--- playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_build_dir.c
(original)
+++ playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_build_dir.c Thu Jul
9
21:17:20 2009
@@ -33,6 +33,7 @@
#endif
#include <sys/stat.h>
+#include <sys/errno.h>
#include <dirent.h>
#include "include/util.h"
@@ -66,13 +67,13 @@
fd = open(path, O_RDONLY);
if (fd < 0) {
perror("open");
- return -1;
+ return 0;
}
/* We need the entire file size */
if (fstat(fd, &sb) < 0) {
perror("fstat");
- return -1;
+ return 0;
}
len = read(fd, buf, BUFSIZE);
@@ -80,7 +81,7 @@
if (! parse_header(buf, len, re)) {
close(fd);
- return -1;
+ return 0;
}
re->file_size = sb.st_size;
close(fd);
@@ -104,7 +105,7 @@
memcpy(&sd.key, re->md5_key, sizeof(sd.key));
if (! write(1, &sd, sizeof(sd)))
- return -1;
+ return 0;
return 1;
}
@@ -153,7 +154,11 @@
rebuild_entry_init(&re);
(void) read_file(path, &re);
re.swap_filen = fn;
- (void) write_swaplog_entry(&re);
+ if (! write_swaplog_entry(&re)) {
+ debug(47, 1) ("read_dir: write()
failed: (%d) %s\n", errno,
xstrerror());
+ rebuild_entry_done(&re);
+ return;
+ }
rebuild_entry_done(&re);
}
Modified: playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_build_log.c
==============================================================================
--- playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_build_log.c
(original)
+++ playpen/LUSCA_HEAD_storework/app/ufs_rebuild/ufs_build_log.c Thu Jul
9
21:17:20 2009
@@ -22,7 +22,7 @@
#include <fcntl.h>
#endif
-#include <dirent.h>
+#include <errno.h>
#include "include/util.h"
#include "include/squid_md5.h"
@@ -61,7 +61,7 @@
r = fread(buf, s, 1, fp);
if (r != 1) {
debug(1, 2) ("fread: returned %d (ferror %d)\n", r, ferror(fp));
- return -1;
+ return 0;
}
num_objects++;
@@ -75,7 +75,10 @@
/* is it an ADD/DEL? Good. If not - count error and continue */
if (sd.op == SWAP_LOG_ADD || sd.op == SWAP_LOG_DEL) {
num_valid_objects++;
- write(1, &sd, sizeof(sd));
+ if (write(1, &sd, sizeof(sd)) < 0) {
+ debug(47, 1) ("write failed: (%d) %s\n", errno,
xstrerror());
+ return 0;
+ }
} else {
debug(1, 5) ("error! Got swaplog entry op %d?!\n", sd.op);
num_invalid_objects++;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---