diff --git a/aeron-driver/src/main/c/aeron_driver.c b/aeron-driver/src/main/c/aeron_driver.c index ba0f8d4148..abb9848fb4 100644 --- a/aeron-driver/src/main/c/aeron_driver.c +++ b/aeron-driver/src/main/c/aeron_driver.c @@ -84,6 +84,26 @@ int aeron_version_patch() return aeron_patch_version; } +int32_t aeron_semantic_version_compose(uint8_t major, uint8_t minor, uint8_t patch) +{ + return (major << 16) | (minor << 8) | patch; +} + +uint8_t aeron_semantic_version_major(int32_t version) +{ + return (uint8_t)((version >> 16) & 0xFF); +} + +uint8_t aeron_semantic_version_minor(int32_t version) +{ + return (uint8_t)((version >> 8) & 0xFF); +} + +uint8_t aeron_semantic_version_patch(int32_t version) +{ + return (uint8_t)(version & 0xFF); +} + void aeron_log_func_stderr(const char *str) { fprintf(stderr, "%s\n", str); @@ -203,7 +223,7 @@ int aeron_report_existing_errors(aeron_mapped_file_t *cnc_map, const char *aeron aeron_cnc_metadata_t *metadata = (aeron_cnc_metadata_t *)cnc_map->addr; - if (AERON_CNC_VERSION == metadata->cnc_version && + if (aeron_semantic_version_major(AERON_CNC_VERSION) == aeron_semantic_version_major(metadata->cnc_version) && aeron_error_log_exists(aeron_cnc_error_log_buffer(cnc_map->addr), (size_t)metadata->error_log_buffer_length)) { char datestamp[AERON_MAX_PATH]; @@ -1019,5 +1039,14 @@ int aeron_driver_close(aeron_driver_t *driver) } aeron_free(driver); + return 0; } + +extern int32_t aeron_semantic_version_compose(uint8_t major, uint8_t minor, uint8_t patch); + +extern uint8_t aeron_semantic_version_major(int32_t version); + +extern uint8_t aeron_semantic_version_minor(int32_t version); + +extern uint8_t aeron_semantic_version_patch(int32_t version); \ No newline at end of file diff --git a/aeron-driver/src/main/c/aeron_driver.h b/aeron-driver/src/main/c/aeron_driver.h index 324c61e796..6b61d6b6a9 100644 --- a/aeron-driver/src/main/c/aeron_driver.h +++ b/aeron-driver/src/main/c/aeron_driver.h @@ -43,4 +43,14 @@ aeron_driver_t; bool aeron_is_driver_active_with_cnc( aeron_mapped_file_t *cnc_map, int64_t timeout_ms, int64_t now_ms, aeron_log_func_t log_func); +int32_t aeron_semantic_version_compose(uint8_t major, uint8_t minor, uint8_t patch); + +uint8_t aeron_semantic_version_major(int32_t version); + +uint8_t aeron_semantic_version_minor(int32_t version); + +uint8_t aeron_semantic_version_patch(int32_t version); + +#define AERON_CNC_VERSION (aeron_semantic_version_compose(0, 0, 15)) + #endif //AERON_DRIVER_H diff --git a/aeron-driver/src/main/c/aeron_driver_context.c b/aeron-driver/src/main/c/aeron_driver_context.c index 9637ef4c71..8763910be1 100644 --- a/aeron-driver/src/main/c/aeron_driver_context.c +++ b/aeron-driver/src/main/c/aeron_driver_context.c @@ -48,6 +48,7 @@ #include "protocol/aeron_udp_protocol.h" #include "util/aeron_parse_util.h" #include "util/aeron_fileutil.h" +#include "aeron_driver.h" #include "aeron_driver_context.h" #include "aeron_alloc.h" #include "concurrent/aeron_mpsc_rb.h" @@ -903,12 +904,18 @@ bool aeron_is_driver_active_with_cnc( aeron_micro_sleep(1000); } - if (AERON_CNC_VERSION != cnc_version) + if (aeron_semantic_version_major(AERON_CNC_VERSION) != aeron_semantic_version_major(cnc_version)) { snprintf( buffer, sizeof(buffer) - 1, - "ERROR: aeron cnc version does not match: file version=%d software version=%d", - cnc_version, AERON_CNC_VERSION); + "ERROR: aeron cnc version not compatible: app version=%d.%d.%d file=%d.%d.%d", + (int)aeron_semantic_version_major(AERON_CNC_VERSION), + (int)aeron_semantic_version_minor(AERON_CNC_VERSION), + (int)aeron_semantic_version_patch(AERON_CNC_VERSION), + (int)aeron_semantic_version_major(cnc_version), + (int)aeron_semantic_version_minor(cnc_version), + (int)aeron_semantic_version_patch(cnc_version)); + log_func(buffer); } else @@ -923,8 +930,8 @@ bool aeron_is_driver_active_with_cnc( } else { - int64_t timestamp = aeron_mpsc_rb_consumer_heartbeat_time_value(&rb); - int64_t diff = now_ms - timestamp; + int64_t timestamp_ms = aeron_mpsc_rb_consumer_heartbeat_time_value(&rb); + int64_t diff = now_ms - timestamp_ms; snprintf(buffer, sizeof(buffer) - 1, "INFO: Aeron driver heartbeat is %" PRId64 " ms old", diff); log_func(buffer); diff --git a/aeron-driver/src/main/c/aeron_driver_context.h b/aeron-driver/src/main/c/aeron_driver_context.h index 54b3f049a3..2eb89407ab 100644 --- a/aeron-driver/src/main/c/aeron_driver_context.h +++ b/aeron-driver/src/main/c/aeron_driver_context.h @@ -30,7 +30,6 @@ #define AERON_CNC_FILE "cnc.dat" #define AERON_LOSS_REPORT_FILE "loss-report.dat" -#define AERON_CNC_VERSION (15) #pragma pack(push) #pragma pack(4)