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