@@ -42,12 +42,14 @@ namespace uplink {
4242
4343 const std::string WS_uplink::UPLINK_CFG_FILE{" config.json" };
4444
45- void * UPDATE_LOC = (void *) 0x3200000 ; // at 50mb
46-
4745 WS_uplink::WS_uplink (net::Inet<net::IP4>& inet)
4846 : inet_{inet}, id_{inet.link_addr ().to_string ()},
4947 parser_ ({this , &WS_uplink::handle_transport})
5048 {
49+ // This is not totally safe...
50+ LIVEUPD_LOCATION = (void *) (OS::heap_max () - 0x2000000 ); // 32MB below heap_max
51+ MYINFO (" Maximum heap at (%p), assigning liveupdate location 32MB below (%p)" , (void *)OS::heap_max (), LIVEUPD_LOCATION);
52+
5153 OS::add_stdout ({this , &WS_uplink::send_log});
5254
5355 read_config ();
@@ -71,10 +73,10 @@ namespace uplink {
7173 Expects (inet.ip_addr () != 0 && " Network interface not configured" );
7274 Expects (not config_.url .empty ());
7375
74- if (liu::LiveUpdate::is_resumable (UPDATE_LOC ))
76+ if (liu::LiveUpdate::is_resumable (LIVEUPD_LOCATION ))
7577 {
7678 MYINFO (" Found resumable state, try restoring..." );
77- auto success = liu::LiveUpdate::resume (UPDATE_LOC , {this , &WS_uplink::restore});
79+ auto success = liu::LiveUpdate::resume (LIVEUPD_LOCATION , {this , &WS_uplink::restore});
7880 CHECK (success, " Success" );
7981 }
8082
@@ -256,7 +258,7 @@ namespace uplink {
256258 ws_->close ();
257259 // do the update
258260 Timers::oneshot (std::chrono::milliseconds (10 ), [this , buffer] (auto ) {
259- liu::LiveUpdate::begin (UPDATE_LOC , buffer, {this , &WS_uplink::store});
261+ liu::LiveUpdate::begin (LIVEUPD_LOCATION , buffer, {this , &WS_uplink::store});
260262 });
261263 }
262264
0 commit comments