Skip to content

Commit

Permalink
Change build filename & fix large file installing by changing heartbeat
Browse files Browse the repository at this point in the history
runner
  • Loading branch information
NyaMisty committed Aug 21, 2021
1 parent a9f97b7 commit 2e9665d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.o
*.a
/AltServer
/AltServerNet
/AltServerUPnP

.vscode/**
.ccls-cache/**
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
PROGRAM := AltServer
ifdef NO_USBMUXD_STUB
PROGRAM := AltServer
else
ifdef NO_UPNP_STUB
PROGRAM := AltServerNet
else
PROGRAM := AltServerUPnP
endif
endif


%.c.o : %.c
$(CC) $(CFLAGS) $(EXTRA_FLAGS) -o $@ -c $<
Expand Down
22 changes: 14 additions & 8 deletions src/AltServerMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ std::vector<unsigned char> readFile(const char* filename)
}

#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>

boost::asio::io_service io_service;
boost::posix_time::seconds interval(15); // 1 second
std::shared_ptr<boost::asio::deadline_timer> timer;
std::shared_ptr<boost::asio::steady_timer> timer;
void *hbclient;

void heartbeat_tick(const boost::system::error_code& /*e*/) {
Expand All @@ -81,19 +81,25 @@ void heartbeat_tick(const boost::system::error_code& /*e*/) {
if (!intervalSec) {
return;
}
interval = boost::posix_time::seconds(intervalSec);
// Reschedule the timer for 1 second in the future:
timer->expires_at(timer->expires_at() + interval);
//timer->expires_from_now(boost::posix_time::seconds(4));
// Posts the timer event
timer->async_wait(heartbeat_tick);
//timer->async_wait(heartbeat_tick);

auto &ioService = crossplat::threadpool::shared_instance().service();
boost::asio::steady_timer t(ioService, std::chrono::seconds(4));
t.async_wait(heartbeat_tick);
}

int setupHeartbeatTimer() {
auto &ioService = crossplat::threadpool::shared_instance().service();

timer = std::make_shared<boost::asio::deadline_timer>(ioService);
timer->expires_from_now(boost::posix_time::seconds(1));
timer->async_wait(heartbeat_tick);
// timer = std::make_shared<boost::asio::steady_timer>(ioService);
// timer->expires_from_now(boost::posix_time::seconds(1));
// timer->async_wait(heartbeat_tick);

boost::system::error_code err;
heartbeat_tick(err);
return 1;
}

Expand Down

0 comments on commit 2e9665d

Please sign in to comment.