[Redbutton-devel] SF.net SVN: redbutton: [291] redbutton-download/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-04-25 09:44:41
|
Revision: 291
http://svn.sourceforge.net/redbutton/?rev=291&view=rev
Author: skilvington
Date: 2007-04-25 02:44:10 -0700 (Wed, 25 Apr 2007)
Log Message:
-----------
don't kill the downloader if a module is corrupt, try to download it again
Modified Paths:
--------------
redbutton-download/trunk/biop.c
redbutton-download/trunk/biop.h
redbutton-download/trunk/module.c
Modified: redbutton-download/trunk/biop.c
===================================================================
--- redbutton-download/trunk/biop.c 2007-04-24 10:38:53 UTC (rev 290)
+++ redbutton-download/trunk/biop.c 2007-04-25 09:44:10 UTC (rev 291)
@@ -33,9 +33,10 @@
/*
* split the module into separate BIOP messages
+ * returns false if the format is invalid
*/
-void
+bool
process_biop(struct carousel *car, struct module *mod, struct BIOPMessageHeader *data, uint32_t size)
{
uint32_t bytes_left;
@@ -64,11 +65,17 @@
|| data->biop_version.major != BIOP_VSN_MAJOR
|| data->biop_version.minor != BIOP_VSN_MINOR
|| data->message_type != BIOP_MSG_TYPE)
- fatal("Invalid BIOP header");
+ {
+ error("Invalid BIOP header");
+ return false;
+ }
size = biop_uint32(data->byte_order, data->message_size);
vverbose("BIOP message_size=%u", size);
if(bytes_left < sizeof(struct BIOPMessageHeader) + size)
- fatal("Not enough BIOP data");
+ {
+ error("Not enough BIOP data");
+ return false;
+ }
/* process MessageSubHeader */
subhdr = ((unsigned char *) data) + sizeof(struct BIOPMessageHeader);
vhexdump(subhdr, size);
@@ -132,14 +139,14 @@
}
else
{
- fatal("Unknown BIOP object: '%.*s'", kind.size, kind.data);
+ error("Ignoring unknown BIOP object: '%.*s'", kind.size, kind.data);
}
/* move onto the next */
data = (struct BIOPMessageHeader *) (((unsigned char *) data) + sizeof(struct BIOPMessageHeader) + size);
bytes_left -= sizeof(struct BIOPMessageHeader) + size;
}
- return;
+ return true;
}
/*
Modified: redbutton-download/trunk/biop.h
===================================================================
--- redbutton-download/trunk/biop.h 2007-04-24 10:38:53 UTC (rev 290)
+++ redbutton-download/trunk/biop.h 2007-04-25 09:44:10 UTC (rev 291)
@@ -100,7 +100,7 @@
};
/* functions */
-void process_biop(struct carousel *, struct module *, struct BIOPMessageHeader *, uint32_t);
+bool process_biop(struct carousel *, struct module *, struct BIOPMessageHeader *, uint32_t);
void process_biop_dir(uint8_t, char *, struct carousel *, unsigned char *, uint32_t);
uint32_t process_iop_ior(uint8_t, unsigned char *, struct biop_iop_ior *);
uint16_t process_biop_service_gateway_info(uint16_t, struct assoc *, unsigned char *, uint16_t);
Modified: redbutton-download/trunk/module.c
===================================================================
--- redbutton-download/trunk/module.c 2007-04-24 10:38:53 UTC (rev 290)
+++ redbutton-download/trunk/module.c 2007-04-25 09:44:10 UTC (rev 291)
@@ -145,11 +145,20 @@
uncompress_module(mod);
verbose("uncompressed size=%u", mod->size);
}
- process_biop(car, mod, (struct BIOPMessageHeader *) mod->data, mod->size);
- /* we can free the data now, keep got_block so we don't download it again */
- safe_free(mod->data);
- /* delete_module may safe_free it again */
- mod->data = NULL;
+ if(process_biop(car, mod, (struct BIOPMessageHeader *) mod->data, mod->size))
+ {
+ /* we can free the data now, keep got_block so we don't download it again */
+ safe_free(mod->data);
+ /* delete_module may safe_free it again */
+ mod->data = NULL;
+ }
+ else
+ {
+ /* failed to process it, try downloading it again */
+ mod->blocks_left = mod->nblocks;
+ /* assumes false == 0 */
+ bzero(mod->got_block, mod->nblocks * sizeof(bool));
+ }
}
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|