@@ -34,7 +34,7 @@ extern char* heap_end;
3434
3535namespace liu
3636{
37- static void resume_begin (storage_header&, std::string, LiveUpdate::resume_func);
37+ static bool resume_begin (storage_header&, std::string, LiveUpdate::resume_func);
3838
3939bool LiveUpdate::is_resumable ()
4040{
@@ -45,17 +45,17 @@ bool LiveUpdate::is_resumable(void* location)
4545 return ((storage_header*) location)->validate ();
4646}
4747
48- static void resume_helper (void * location, std::string key, LiveUpdate::resume_func func)
48+ static bool resume_helper (void * location, std::string key, LiveUpdate::resume_func func)
4949{
5050 // check if an update has occurred
5151 if (!LiveUpdate::is_resumable (location))
52- throw std::runtime_error ( " Trying to resume from invalid storage area " ) ;
52+ return false ;
5353
5454 LPRINT (" * Restoring data...\n " );
5555 // restore connections etc.
56- resume_begin (*(storage_header*) location, key.c_str (), func);
56+ return resume_begin (*(storage_header*) location, key.c_str (), func);
5757}
58- void LiveUpdate::resume (std::string key, resume_func func)
58+ bool LiveUpdate::resume (std::string key, resume_func func)
5959{
6060 void * location = OS::liveupdate_storage_area ();
6161 // / memory sanity check
@@ -65,19 +65,20 @@ void LiveUpdate::resume(std::string key, resume_func func)
6565 (long int ) (heap_end - (char *) location));
6666 throw std::runtime_error (" LiveUpdate storage area inside heap" );
6767 }
68- resume_helper (location, std::move (key), func);
68+ return resume_helper (location, std::move (key), func);
6969}
7070void LiveUpdate::resume_from_heap (void * location, std::string key, LiveUpdate::resume_func func)
7171{
7272 resume_helper (location, std::move (key), func);
7373}
7474
75- void resume_begin (storage_header& storage, std::string key, LiveUpdate::resume_func func)
75+ bool resume_begin (storage_header& storage, std::string key, LiveUpdate::resume_func func)
7676{
7777 if (key.empty ())
7878 throw std::length_error (" LiveUpdate partition key cannot be an empty string" );
7979
8080 int p = storage.find_partition (key.c_str ());
81+ if (p == -1 ) return false ;
8182 LPRINT (" * Resuming from partition %d at %p from %p\n " ,
8283 p, storage.begin (p), &storage);
8384
@@ -92,6 +93,7 @@ void resume_begin(storage_header& storage, std::string key, LiveUpdate::resume_f
9293 storage.zero_partition (p);
9394 // if there are no more partitions, clear everything
9495 storage.try_zero ();
96+ return true ;
9597}
9698
9799// / struct Restore
0 commit comments