summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2023-06-28 10:06:59 +0800
committerluwenpeng <[email protected]>2023-06-28 10:06:59 +0800
commit630b7c4212974e743c36691fb25e3b435f3584af (patch)
tree1392df5aca187b2d987600bfc5c0b2aff1a37de4
parent66b83bf37838a935995ddec28449455a1a8081f3 (diff)
hasp_monitor检测到授权过期后重新login尝试获取新的授权v1.0.7-20230628
-rw-r--r--platform/src/hasp_verify.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/platform/src/hasp_verify.c b/platform/src/hasp_verify.c
index dbf1f47..939f5e3 100644
--- a/platform/src/hasp_verify.c
+++ b/platform/src/hasp_verify.c
@@ -568,45 +568,48 @@ static void *hasp_monitor_cycle(void *arg)
signal(SIGUSR1, signal_handler);
signal(SIGUSR2, signal_handler);
- hasp_handle_t handle;
- hasp_status_t status = hasp_login(hasp_monitor_feature_id, (hasp_vendor_code_t)vendor_code, &handle);
- if (status != HASP_STATUS_OK)
- {
- log_hasp_status(status);
- goto error_out;
- }
-
while (1)
{
- status = encrypt_decrypt(handle);
- if (status == HASP_STATUS_OK)
+ hasp_handle_t handle;
+ hasp_status_t status = hasp_login(hasp_monitor_feature_id, (hasp_vendor_code_t)vendor_code, &handle);
+ if (status != HASP_STATUS_OK)
+ {
+ goto error_logout;
+ }
+
+ while (1)
{
- memset(&data, 0, sizeof(data));
- data.feature_id = hasp_monitor_feature_id;
- data.status = 1;
- data.timestamp = current_timestamp();
- data.interval = hasp_monitor_interval;
- if (hasp_monitor_write(&data) == 0)
+ status = encrypt_decrypt(handle);
+ if (status == HASP_STATUS_OK)
{
- LOG_DEBUG("hasp_monitor: Set feature_id: %ld, timestamp: %ld, interval: %ld, status: %ld", data.feature_id, data.timestamp, data.interval, data.status);
+ memset(&data, 0, sizeof(data));
+ data.feature_id = hasp_monitor_feature_id;
+ data.status = 1;
+ data.timestamp = current_timestamp();
+ data.interval = hasp_monitor_interval;
+ if (hasp_monitor_write(&data) == 0)
+ {
+ LOG_DEBUG("hasp_monitor: Set feature_id: %ld, timestamp: %ld, interval: %ld, status: %ld", data.feature_id, data.timestamp, data.interval, data.status);
+ }
+ else
+ {
+ // continue while loop
+ }
}
else
{
- // continue while loop
+ goto error_logout;
}
- }
- else
- {
- log_hasp_status(status);
- // continue while loop
+
+ sleep(hasp_monitor_interval);
}
- sleep(hasp_monitor_interval);
+ error_logout:
+ log_hasp_status(status);
+ hasp_logout(handle);
+ sleep(1);
}
-error_out:
- hasp_logout(handle);
-
return NULL;
}