TSG-23932: Support parsing session_uuid field

This commit is contained in:
wangmenglan
2024-11-28 15:18:30 +08:00
parent dd4e2e6d66
commit 59e7f7a6a3
3 changed files with 29 additions and 3 deletions

View File

@@ -390,6 +390,16 @@ static int proxy_parse_messagepack(mpack_node_t node, void *ctx, void *logger)
break; break;
} }
} }
mpack_node_t node_session_uuid;
uuid_t session_uuid;
if (mpack_node_is_nil(mpack_node_map_cstr(node, "session_uuid")))
goto done;
node_session_uuid = mpack_node_map_cstr(node, "session_uuid");
if (mpack_parse_uuid(node_session_uuid, session_uuid) != -1)
tfe_cmsg_set(handler->cmsg, TFE_CMSG_STREAM_TRACE_ID, (const unsigned char*)session_uuid, UUID_LEN);
done:
return 0; return 0;
} }
@@ -570,6 +580,7 @@ void ctrl_packet_parser_dump(struct ctrl_pkt_parser *handler, void *logger)
int map_index = 0; int map_index = 0;
char *log_str = NULL; char *log_str = NULL;
uuid_t tags_ids_array[128]; uuid_t tags_ids_array[128];
uuid_t session_uuid;
int log_len = 0; int log_len = 0;
log_str = (char *)calloc(1, LOG_STR_LEN); log_str = (char *)calloc(1, LOG_STR_LEN);
@@ -684,6 +695,17 @@ void ctrl_packet_parser_dump(struct ctrl_pkt_parser *handler, void *logger)
} }
} }
} }
ret = tfe_cmsg_get_value(handler->cmsg, TFE_CMSG_STREAM_TRACE_ID, (unsigned char *)session_uuid, UUID_LEN, &size);
if (ret < 0) {
log_len += snprintf(log_str + log_len, LOG_STR_LEN - log_len, ", session_uuid:null");
}
else {
char str_session_uuid[UUID_STRING_SIZE] = {0};
uuid_unparse(session_uuid, str_session_uuid);
log_len += snprintf(log_str + log_len, LOG_STR_LEN - log_len, ", session_uuid:%s", str_session_uuid);
}
TFE_LOG_DEBUG(logger, "%s", log_str); TFE_LOG_DEBUG(logger, "%s", log_str);
free(log_str); free(log_str);
log_str = NULL; log_str = NULL;

View File

@@ -1255,8 +1255,6 @@ static int handle_session_opening(struct metadata *meta, marsio_buff_t *rx_buff,
stream_common_direction = meta->is_e2i_dir ? 'I' : 'E'; stream_common_direction = meta->is_e2i_dir ? 'I' : 'E';
tfe_cmsg_set(parser->cmsg, TFE_CMSG_COMMON_DIRECTION, (const uint8_t *)&stream_common_direction, sizeof(stream_common_direction)); tfe_cmsg_set(parser->cmsg, TFE_CMSG_COMMON_DIRECTION, (const uint8_t *)&stream_common_direction, sizeof(stream_common_direction));
snprintf(stream_traceid, 24, "%" PRIu64, meta->session_id);
tfe_cmsg_set(parser->cmsg, TFE_CMSG_STREAM_TRACE_ID, (const uint8_t *)stream_traceid, strlen(stream_traceid));
tfe_cmsg_dup(parser->cmsg); tfe_cmsg_dup(parser->cmsg);
// 为避免 packet IO thread 与 worker 访问 cmsg 时出现竞争packet IO thread 必须在调用 tfe_proxy_fds_accept 之前 set cmsg // 为避免 packet IO thread 与 worker 访问 cmsg 时出现竞争packet IO thread 必须在调用 tfe_proxy_fds_accept 之前 set cmsg

View File

@@ -170,8 +170,14 @@ void build_mpack_data(char **data, size_t *size)
mpack_write_bin(&writer, (const char*)seq_header, sizeof(seq_header)); mpack_write_bin(&writer, (const char*)seq_header, sizeof(seq_header));
mpack_write_bin(&writer, (const char*)ack_header, sizeof(ack_header)); mpack_write_bin(&writer, (const char*)ack_header, sizeof(ack_header));
mpack_write_u8(&writer, tfe_flag); mpack_write_u8(&writer, tfe_flag);
mpack_complete_array(&writer); mpack_complete_array(&writer);
mpack_write_cstr(&writer, "session_uuid");
uuid_generate(uuid);
uuid_unparse(uuid, str_uuid);
printf("session_uuid:%s\n", str_uuid);
mpack_write_bin(&writer, (const char*)uuid, sizeof(uuid));
mpack_complete_map(&writer); mpack_complete_map(&writer);
mpack_complete_map(&writer); mpack_complete_map(&writer);
mpack_complete_map(&writer); mpack_complete_map(&writer);