Bugfix: Address incorrect formatting specifiers, and add "format" attribute to datum_logger_queue_msg

This commit is contained in:
Luke Dashjr 2024-10-20 17:00:26 +00:00
parent 900b595db7
commit 40ff91b531
No known key found for this signature in database
GPG Key ID: A291A2C45D0C504A
7 changed files with 18 additions and 17 deletions

View File

@ -460,7 +460,7 @@ void *datum_gateway_template_thread(void *args) {
// use this template to setup for a coinbaser wait job while the empty + full w/blank jobs are blasted
// then this job will get blasted when its ready.
i = datum_stratum_v1_global_subscriber_count();
DLOG_INFO("Updating priority stratum job for block %d: %.8f BTC, %d txns, %d bytes (Sent to %d stratum client%s)", t->height, (double)t->coinbasevalue / (double)100000000.0, t->txn_count, t->txn_total_size, i, (i!=1)?"s":"");
DLOG_INFO("Updating priority stratum job for block %lu: %.8f BTC, %lu txns, %lu bytes (Sent to %llu stratum client%s)", (unsigned long)t->height, (double)t->coinbasevalue / (double)100000000.0, (unsigned long)t->txn_count, (unsigned long)t->txn_total_size, (unsigned long long)i, (i!=1)?"s":"");
update_stratum_job(t,false,JOB_STATE_FULL_PRIORITY_WAIT_COINBASER);
} else {
if (was_notified) {
@ -513,7 +513,7 @@ void *datum_gateway_template_thread(void *args) {
t->curtime += 1200;
}
DLOG_DEBUG("t->curtime = %d",t->curtime);
DLOG_DEBUG("t->curtime = %llu", (unsigned long long)t->curtime);
update_stratum_job(t,true,JOB_STATE_FULL_PRIORITY_WAIT_COINBASER);
new_notify_blockhash[0] = 0;
@ -522,7 +522,7 @@ void *datum_gateway_template_thread(void *args) {
}
} else {
i = datum_stratum_v1_global_subscriber_count();
DLOG_INFO("Updating standard stratum job for block %d: %.8f BTC, %d txns, %d bytes (Sent to %d stratum client%s)", t->height, (double)t->coinbasevalue / (double)100000000.0, t->txn_count, t->txn_total_size, i, (i!=1)?"s":"");
DLOG_INFO("Updating standard stratum job for block %lu: %.8f BTC, %lu txns, %lu bytes (Sent to %llu stratum client%s)", (unsigned long)t->height, (double)t->coinbasevalue / (double)100000000.0, (unsigned long)t->txn_count, (unsigned long)t->txn_total_size, (unsigned long long)i, (i!=1)?"s":"");
update_stratum_job(t,false,JOB_STATE_FULL_NORMAL_WAIT_COINBASER);
}
}

View File

@ -347,8 +347,9 @@ int datum_read_config(const char *conffile) {
}
if (roundDownToPowerOfTwo_64(datum_config.stratum_v1_vardiff_min) != datum_config.stratum_v1_vardiff_min) {
DLOG_WARN("stratum.stratum_v1_vardiff_min MUST be a power of two. adjusting from %d to %d", datum_config.stratum_v1_vardiff_min, roundDownToPowerOfTwo_64(datum_config.stratum_v1_vardiff_min));
datum_config.stratum_v1_vardiff_min = roundDownToPowerOfTwo_64(datum_config.stratum_v1_vardiff_min);
const int nv = roundDownToPowerOfTwo_64(datum_config.stratum_v1_vardiff_min);
DLOG_WARN("stratum.stratum_v1_vardiff_min MUST be a power of two. adjusting from %d to %d", datum_config.stratum_v1_vardiff_min, nv);
datum_config.stratum_v1_vardiff_min = nv;
}
if (datum_config.stratum_v1_vardiff_min < 1) {

View File

@ -173,7 +173,7 @@ int main(int argc, char **argv) {
// Try to connect to the DATUM server, if setup to do so.
if (datum_config.datum_pool_host[0] != 0) {
while((current_time_millis()-15000 < last_datum_protocol_connect_tsms) && (!datum_protocol_is_active())) {
DLOG_INFO("Waiting on DATUM server... %d", (last_datum_protocol_connect_tsms-(current_time_millis()-15000))/1000);
DLOG_INFO("Waiting on DATUM server... %d", (int)((last_datum_protocol_connect_tsms-(current_time_millis()-15000))/1000));
sleep(1);
if ((datum_config.datum_pool_host[0] != 0) && (!datum_protocol_thread_is_active())) {
datum_protocol_start_connector();

View File

@ -58,7 +58,7 @@ typedef struct {
#define DLOG_LEVEL_FATAL 5
void datum_logger(const char *func, int level, const char *format, ...);
int datum_logger_queue_msg(const char *func, int level, const char *format, ...);
int datum_logger_queue_msg(const char *func, int level, const char *format, ...) __attribute__((format(printf, 3, 4)));
// Generic for dynamic log level messages
#define DLOG(level, format, ...) datum_logger_queue_msg(__func__, level, format __VA_OPT__(,) __VA_ARGS__)

View File

@ -651,7 +651,7 @@ void *datum_gateway_listener_thread(void *arg) {
if (rejecting_now) {
reject_count++;
if ((curtime_tsms - last_reject_msg_tsms) > 5000) {
DLOG_INFO("DATUM not connected and configured for pooled mining only! Rejecting connection. (%d connections rejected since last noted)", reject_count);
DLOG_INFO("DATUM not connected and configured for pooled mining only! Rejecting connection. (%llu connections rejected since last noted)", (unsigned long long)reject_count);
last_reject_msg_tsms = curtime_tsms;
reject_count = 0;
}

View File

@ -141,7 +141,7 @@ void *datum_stratum_v1_socket_server(void *arg) {
// Setup the socket "app" for Stratum V1
app = (T_DATUM_SOCKET_APP *)calloc(1,sizeof(T_DATUM_SOCKET_APP));
if (!app) {
DLOG_FATAL("Could not allocate memory for Stratum V1 server app metadata! (%d bytes)", sizeof(T_DATUM_SOCKET_APP));
DLOG_FATAL("Could not allocate memory for Stratum V1 server app metadata! (%lu bytes)", (unsigned long)sizeof(T_DATUM_SOCKET_APP));
panic_from_thread(__LINE__);
return NULL;
}
@ -172,7 +172,7 @@ void *datum_stratum_v1_socket_server(void *arg) {
// allocate memory for DATUM socket thread data
app->datum_threads = (T_DATUM_THREAD_DATA *) calloc(app->max_threads + 1, sizeof(T_DATUM_THREAD_DATA));
if (!app->datum_threads) {
DLOG_FATAL("Could not allocate memory for Stratum V1 server thread pool data! (%d bytes)", (sizeof(T_DATUM_THREAD_DATA) * (app->max_threads + 1)));
DLOG_FATAL("Could not allocate memory for Stratum V1 server thread pool data! (%lu bytes)", (unsigned long)(sizeof(T_DATUM_THREAD_DATA) * (app->max_threads + 1)));
panic_from_thread(__LINE__);
return NULL;
}
@ -182,7 +182,7 @@ void *datum_stratum_v1_socket_server(void *arg) {
// allocate once for the whole chunk, and set the pointers. no need to do tons of calls for a static block of data
app->datum_threads[0].app_thread_data = calloc(app->max_threads + 1, sizeof(T_DATUM_STRATUM_THREADPOOL_DATA));
if (!app->datum_threads[0].app_thread_data) {
DLOG_FATAL("Could not allocate memory for Stratum V1 server thread pool app data! (%d bytes)", (sizeof(T_DATUM_STRATUM_THREADPOOL_DATA) * (app->max_threads + 1)));
DLOG_FATAL("Could not allocate memory for Stratum V1 server thread pool app data! (%lu bytes)", (unsigned long)(sizeof(T_DATUM_STRATUM_THREADPOOL_DATA) * (app->max_threads + 1)));
panic_from_thread(__LINE__);
return NULL;
}
@ -197,7 +197,7 @@ void *datum_stratum_v1_socket_server(void *arg) {
// T_DATUM_MINER_DATA
app->datum_threads[0].client_data[0].app_client_data = calloc(((app->max_threads*app->max_clients_thread)+1), sizeof(T_DATUM_MINER_DATA));
if (!app->datum_threads[0].client_data[0].app_client_data) {
DLOG_FATAL("Could not allocate memory for Stratum V1 server per-client data! (%d bytes)", ((app->max_threads*app->max_clients_thread)+1) * sizeof(T_DATUM_MINER_DATA));
DLOG_FATAL("Could not allocate memory for Stratum V1 server per-client data! (%lu bytes)", (unsigned long)(((app->max_threads*app->max_clients_thread)+1) * sizeof(T_DATUM_MINER_DATA)));
panic_from_thread(__LINE__);
return NULL;
}
@ -258,10 +258,10 @@ void *datum_stratum_v1_socket_server(void *arg) {
// TODO: If limits are too low, attempt to set our ulimits in case we're allowed to do so but it hasn't been done before executing.
if (!getrlimit(RLIMIT_NOFILE, &rlimit)) {
if (app->max_clients > rlimit.rlim_max) {
DLOG_WARN("*** NOTE *** Max Stratum clients (%d) exceeds hard open file limit (Soft: %d / Hard: %d)", app->max_clients, rlimit.rlim_cur, rlimit.rlim_max);
DLOG_WARN("*** NOTE *** Max Stratum clients (%llu) exceeds hard open file limit (Soft: %llu / Hard: %llu)", (unsigned long long)app->max_clients, (unsigned long long)rlimit.rlim_cur, (unsigned long long)rlimit.rlim_max);
DLOG_WARN("*** NOTE *** Adjust max open file hard limit or you WILL run into issues before reaching max clients!");
} else if (app->max_clients > rlimit.rlim_cur) {
DLOG_WARN("*** NOTE *** Max Stratum clients (%d) exceeds open file soft limit (Soft: %d / Hard: %d)", app->max_clients, rlimit.rlim_cur, rlimit.rlim_max);
DLOG_WARN("*** NOTE *** Max Stratum clients (%llu) exceeds open file soft limit (Soft: %llu / Hard: %llu)", (unsigned long long)app->max_clients, (unsigned long long)rlimit.rlim_cur, (unsigned long long)rlimit.rlim_max);
DLOG_WARN("*** NOTE *** You should increase the soft open file limit to prevent issues as you approach max clients!");
}
}
@ -278,7 +278,7 @@ void *datum_stratum_v1_socket_server(void *arg) {
if (stratum_latest_empty_complete_count >= app->datum_active_threads) {
// we are done!
stratum_latest_empty_ready_for_full = true;
DLOG_INFO("Empty work send completed. Sent to %d clients across %d threads", stratum_latest_empty_sent_count, stratum_latest_empty_complete_count);
DLOG_INFO("Empty work send completed. Sent to %llu clients across %llu threads", (unsigned long long)stratum_latest_empty_sent_count, (unsigned long long)stratum_latest_empty_complete_count);
}
}
pthread_rwlock_unlock(&stratum_global_latest_empty_stat);

View File

@ -52,7 +52,7 @@ void datum_stratum_dupes_init(void *sdata_v) {
T_DATUM_STRATUM_DUPES *dupes = NULL;
sdata->dupes = calloc( sizeof(T_DATUM_STRATUM_DUPES) + 16, 1 );
if (!sdata->dupes) {
DLOG_FATAL("Could not allocate RAM for dupe struct (small one, %d bytes)",sizeof(T_DATUM_STRATUM_DUPES) + 16);
DLOG_FATAL("Could not allocate RAM for dupe struct (small one, %lu bytes)", (unsigned long)sizeof(T_DATUM_STRATUM_DUPES) + 16);
panic_from_thread(__LINE__);
return;
}
@ -61,7 +61,7 @@ void datum_stratum_dupes_init(void *sdata_v) {
dupes->ptr = calloc((datum_config.stratum_v1_max_clients_per_thread * datum_config.stratum_v1_vardiff_target_shares_min * (datum_config.stratum_v1_share_stale_seconds/60) * 16), sizeof(T_DATUM_STRATUM_DUPE_ITEM) );
if (!dupes->ptr) {
DLOG_FATAL("Could not allocate RAM for dupe struct (big one, %d bytes)",(datum_config.stratum_v1_max_clients_per_thread * datum_config.stratum_v1_vardiff_target_shares_min * (datum_config.stratum_v1_share_stale_seconds/60) * 16) * sizeof(T_DATUM_STRATUM_DUPE_ITEM));
DLOG_FATAL("Could not allocate RAM for dupe struct (big one, %lu bytes)",(unsigned long)(datum_config.stratum_v1_max_clients_per_thread * datum_config.stratum_v1_vardiff_target_shares_min * (datum_config.stratum_v1_share_stale_seconds/60) * 16) * sizeof(T_DATUM_STRATUM_DUPE_ITEM));
panic_from_thread(__LINE__);
return;
}