linux errors
This commit is contained in:
@@ -229,5 +229,6 @@ target_compile_options(node PRIVATE
|
||||
target_compile_definitions(node PRIVATE
|
||||
CHAIN_DATA_DIR="${CMAKE_BINARY_DIR}/chain_data"
|
||||
$<$<BOOL:${SKALACOIN_AUTOLYKOS2_REF_AVAILABLE}>:SKALACOIN_AUTOLYKOS2_REF_AVAILABLE>
|
||||
$<$<BOOL:1>:_POSIX_C_SOURCE=200809L>
|
||||
)
|
||||
set_target_properties(node PROPERTIES OUTPUT_NAME "skalacoin_node")
|
||||
|
||||
@@ -36,6 +36,19 @@ static inline uint64_t get_current_time_ms(void) {
|
||||
return (spec.tv_sec * 1000) + (spec.tv_nsec / 1000000);
|
||||
}
|
||||
|
||||
static inline void sleep_for_microseconds(uint64_t microseconds) {
|
||||
struct timespec req;
|
||||
req.tv_sec = (time_t)(microseconds / 1000000ULL);
|
||||
req.tv_nsec = (long)((microseconds % 1000000ULL) * 1000ULL);
|
||||
while (nanosleep(&req, &req) == -1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void sleep_for_milliseconds(uint64_t milliseconds) {
|
||||
sleep_for_microseconds(milliseconds * 1000ULL);
|
||||
}
|
||||
|
||||
static inline void AddressToHexString(const uint8_t address[32], char out[65]) {
|
||||
if (!address || !out) {
|
||||
return;
|
||||
|
||||
@@ -254,7 +254,7 @@ static bool Autolykos2_HashCore(
|
||||
DWORD ms = (DWORD)((autolykos2_sleepBetweenHashOperationsMicroseconds + 999) / 1000);
|
||||
Sleep(ms);
|
||||
#else
|
||||
usleep((useconds_t)autolykos2_sleepBetweenHashOperationsMicroseconds);
|
||||
sleep_for_microseconds(autolykos2_sleepBetweenHashOperationsMicroseconds);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -830,7 +830,7 @@ int main(int argc, char* argv[]) {
|
||||
// Poll for completions or timeouts
|
||||
if (inFlight == 0) {
|
||||
// nothing in flight; small sleep to avoid busy-loop
|
||||
usleep(100 * 1000);
|
||||
sleep_for_milliseconds(100);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -945,7 +945,7 @@ int main(int argc, char* argv[]) {
|
||||
// retry with exponential backoff
|
||||
retryCount[i]++;
|
||||
uint64_t backoff = SYNC_BACKOFF_BASE_MS * (1ULL << (retryCount[i] - 1));
|
||||
usleep((useconds_t)(backoff * 1000ULL));
|
||||
sleep_for_milliseconds(backoff);
|
||||
|
||||
uint64_t req = requestedHeights[i];
|
||||
if (Node_SendPacket(node, peerConn, PACKET_TYPE_FETCH_BLOCK, &req, sizeof(req)) != 0) {
|
||||
@@ -964,7 +964,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
if (!progressed) {
|
||||
// small sleep to avoid spinning
|
||||
usleep(50 * 1000);
|
||||
sleep_for_milliseconds(50);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ static void* Node_MaintenanceThread(void* arg) {
|
||||
BalanceSheet_SaveToFile(chainDataDir);
|
||||
}
|
||||
}
|
||||
usleep((useconds_t)(n->maintenanceIntervalMs * 1000));
|
||||
sleep_for_milliseconds((uint64_t)n->maintenanceIntervalMs);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user