Commit f458ea35 authored by Mike Hibler's avatar Mike Hibler
Browse files

Change timestamp signature check to check for different not just older.

Previously if you reverted an image to an older version, the check would
not detect it and we would not update cached copies.

Also, improve a couple of info messages.
parent f72e7bc6
......@@ -453,9 +453,9 @@ fetch_parent(struct in_addr *myip, struct in_addr *hostip,
}
if (debug)
info("%s: requesting %simage from %s",
info("%s: requesting %simage from %s:%d",
ii->imageid, (statusonly ? "status of ": ""),
inet_ntoa(*pip));
inet_ntoa(*pip), pport);
/*
* Image fetch is not in progress.
......@@ -736,18 +736,21 @@ handle_get(int sock, struct sockaddr_in *sip, struct sockaddr_in *cip,
* Since this is mirror mode, we can use the status
* info we got from the earlier call.
*
* Note that we actually check for a different date,
* not just a newer date. People often roll back
* faulty images to previous versions.
*
* XXX need checks for other signature types.
*/
if ((reply.sigtype == MS_SIGTYPE_MTIME &&
*(time_t *)reply.signature > sb.st_mtime)) {
*(time_t *)reply.signature != sb.st_mtime)) {
uint32_t mt = *(uint32_t *)reply.signature;;
msg->body.getreply.sigtype =
htons(reply.sigtype);
if (reply.sigtype == MS_SIGTYPE_MTIME) {
uint32_t mt;
mt = *(uint32_t *)reply.signature;
if (reply.sigtype == MS_SIGTYPE_MTIME)
*(uint32_t *)reply.signature =
htonl(mt);
}
memcpy(msg->body.getreply.signature,
reply.signature, MS_MAXSIGLEN);
msg->body.getreply.hisize =
......@@ -758,8 +761,9 @@ handle_get(int sock, struct sockaddr_in *sip, struct sockaddr_in *cip,
if (wantstatus)
goto reply;
log("%s: local copy out of date, "
"GET from parent", imageid);
log("%s: local copy (sig=%x) "
"is out of date (sig=%x), GET from parent",
imageid, sb.st_mtime, mt);
getfromparent = 1;
}
}
......@@ -2189,6 +2193,9 @@ handle_igmp(void)
static struct timeval lastquery;
struct timeval now, delta;
if (lastquery.tv_sec == 0)
gettimeofday(&lastquery, NULL);
gettimeofday(&now, NULL);
timersub(&now, &lastquery, &delta);
if (delta.tv_sec >= igmpqueryinterval) {
......
......@@ -764,7 +764,9 @@ ClientNetFindServer(in_addr_t sip, in_port_t sport,
name.sin_addr.s_addr = htonl(sip);
name.sin_port = htons(sport);
if (connect(msock, (struct sockaddr *)&name, sizeof(name)) < 0) {
perror("Connecting to master server");
fprintf(stderr,
"Connecting to master server %s:%d failed: %s",
inet_ntoa(name.sin_addr), sport, strerror(errno));
close(msock);
return 0;
}
......@@ -818,11 +820,15 @@ ClientNetFindServer(in_addr_t sip, in_port_t sport,
if (strncmp((char *)msg.hdr.version, MS_MSGVERS_1,
sizeof(msg.hdr.version))) {
fprintf(stderr, "Got incorrect version from master server\n");
fprintf(stderr,
"Got incorrect version from master server %s:%d\n",
inet_ntoa(name.sin_addr), sport);
return 0;
}
if (ntohl(msg.hdr.type) != MS_MSGTYPE_GETREPLY) {
fprintf(stderr, "Got incorrect reply from master server\n");
fprintf(stderr,
"Got incorrect reply from master server %s:%d\n",
inet_ntoa(name.sin_addr), sport);
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment