Commit 63824ffe authored by Claes Sjofors's avatar Claes Sjofors

Sev server histdata message size fix for V0

parent 72d04360
...@@ -863,14 +863,17 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size, ...@@ -863,14 +863,17 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size,
sev_sHistData *dp; sev_sHistData *dp;
pwr_tTime time; pwr_tTime time;
pwr_tUInt32 server_thread; pwr_tUInt32 server_thread;
int data_size;
if ( msg->Version == 0) { if ( msg->Version == 0) {
// Server thread was added in version 1 // Server thread was added in version 1
dp = (sev_sHistData *) &((sev_sMsgHistDataStoreV0 *)msg)->Data; dp = (sev_sHistData *) &((sev_sMsgHistDataStoreV0 *)msg)->Data;
data_size = size - (sizeof(sev_sMsgHistDataStoreV0) - sizeof(msg->Data));
server_thread = 0; server_thread = 0;
} }
else { else {
dp = (sev_sHistData *) &msg->Data; dp = (sev_sHistData *) &msg->Data;
data_size = size - (sizeof(*msg) - sizeof(msg->Data));
server_thread = msg->ServerThread; server_thread = msg->ServerThread;
} }
...@@ -919,16 +922,17 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size, ...@@ -919,16 +922,17 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size,
} }
// Create a queue message // Create a queue message
if ( (int)(th->alloc + sizeof(*qmsg) - sizeof(qmsg->data) + size) > (int)m_config->ThreadQueueLimit || qmsg_size = data_size + (sizeof(*qmsg) - sizeof(qmsg->data));
(int)(m_total_queue_cnt + sizeof(*qmsg) - sizeof(qmsg->data) + size) > (int)m_config->TotalQueueLimit) {
if ( (int)(th->alloc + qmsg_size) > (int)m_config->ThreadQueueLimit ||
(int)(m_total_queue_cnt + qmsg_size) > (int)m_config->TotalQueueLimit) {
// Queue maxlimit exceeded, discard message // Queue maxlimit exceeded, discard message
m_config->ServerThreads[th->conf_idx].LostCnt++; m_config->ServerThreads[th->conf_idx].LostCnt++;
return 1; return 1;
} }
qmsg_size = size + (sizeof(*qmsg) - sizeof(qmsg->data)) - (sizeof(*msg) - sizeof(msg->Data));
qmsg = (sev_sQMsgHistData *)malloc( qmsg_size); qmsg = (sev_sQMsgHistData *)malloc( qmsg_size);
memcpy( &qmsg->data, dp, qmsg_size - (sizeof(*qmsg) - sizeof(qmsg->data))); memcpy( &qmsg->data, dp, data_size);
qmsg->h.type = sev_eQMsgType_HistData; qmsg->h.type = sev_eQMsgType_HistData;
qmsg->h.version = msg->Version; qmsg->h.version = msg->Version;
qmsg->h.size = qmsg_size; qmsg->h.size = qmsg_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment