Commit cbf0c841 authored by Claes Sjofors's avatar Claes Sjofors

Sev server threads, refid tree mutex added and compile on 64

parent 62383b1d
...@@ -140,7 +140,7 @@ int rmq_connect() ...@@ -140,7 +140,7 @@ int rmq_connect()
if ( !ctx->conn) { if ( !ctx->conn) {
ctx->conn = amqp_new_connection(); ctx->conn = amqp_new_connection();
printf( "Connection : %u\n", (unsigned int)ctx->conn); // printf( "Connection : %u\n", (unsigned int)ctx->conn);
} }
if ( !ctx->socket) { if ( !ctx->socket) {
...@@ -320,7 +320,7 @@ unsigned int rmq_receive() ...@@ -320,7 +320,7 @@ unsigned int rmq_receive()
printf( "Unknown Reply type: %d\n", ret.reply_type); printf( "Unknown Reply type: %d\n", ret.reply_type);
} }
if (debug) printf("Received message %d\n", envelope.message.body.len); if (debug) printf("Received message %d\n", (int) envelope.message.body.len);
if ( envelope.message.body.len > 0 && rn_rmq->DisableHeader) { if ( envelope.message.body.len > 0 && rn_rmq->DisableHeader) {
......
...@@ -250,7 +250,7 @@ void sev_repair::clean_item( int idx, int print_idx) ...@@ -250,7 +250,7 @@ void sev_repair::clean_item( int idx, int print_idx)
printf( "-- Processing %d (%u) %s\n", idx, (unsigned int)m_db->m_items.size(), m_db->m_items[idx].tablename); printf( "-- Processing %d (%u) %s\n", idx, (unsigned int)m_db->m_items.size(), m_db->m_items[idx].tablename);
else else
printf( "-- Processing %s\n", m_db->m_items[idx].tablename); printf( "-- Processing %s\n", m_db->m_items[idx].tablename);
m_db->delete_old_objectdata( &m_sts, m_db->m_items[idx].tablename, m_db->delete_old_objectdata( &m_sts, 0, m_db->m_items[idx].tablename,
m_db->m_items[idx].options, limit, m_db->m_items[idx].scantime, (float)0xEFFFFFFF); m_db->m_items[idx].options, limit, m_db->m_items[idx].scantime, (float)0xEFFFFFFF);
} }
else { else {
...@@ -258,7 +258,7 @@ void sev_repair::clean_item( int idx, int print_idx) ...@@ -258,7 +258,7 @@ void sev_repair::clean_item( int idx, int print_idx)
printf( "-- Processing %d (%u) %s\n", idx, (unsigned int)m_db->m_items.size(), m_db->m_items[idx].tablename); printf( "-- Processing %d (%u) %s\n", idx, (unsigned int)m_db->m_items.size(), m_db->m_items[idx].tablename);
else else
printf( "-- Processing %s\n", m_db->m_items[idx].tablename); printf( "-- Processing %s\n", m_db->m_items[idx].tablename);
m_db->delete_old_data( &m_sts, m_db->m_items[idx].tablename, m_db->delete_old_data( &m_sts, 0, m_db->m_items[idx].tablename,
m_db->m_items[idx].options, limit, m_db->m_items[idx].scantime, (float)0xEFFFFFFF); m_db->m_items[idx].options, limit, m_db->m_items[idx].scantime, (float)0xEFFFFFFF);
} }
} }
...@@ -428,4 +428,4 @@ int main (int argc, char *argv[]) ...@@ -428,4 +428,4 @@ int main (int argc, char *argv[])
} }
#else #else
int main(){} int main(){}
#endif #endif
\ No newline at end of file
...@@ -216,6 +216,7 @@ int sev_server::init( int noneth) ...@@ -216,6 +216,7 @@ int sev_server::init( int noneth)
m_db->get_objectitems(&m_sts); m_db->get_objectitems(&m_sts);
m_refid = tree_CreateTable(&sts, sizeof(pwr_tRefId), offsetof(sev_sRefid, id), sizeof(sev_sRefid), 100, sev_comp_refid); m_refid = tree_CreateTable(&sts, sizeof(pwr_tRefId), offsetof(sev_sRefid, id), sizeof(sev_sRefid), 100, sev_comp_refid);
sts = thread_MutexInit(&m_refid_mutex);
// Create a queue to server // Create a queue to server
qcom_sQattr attr; qcom_sQattr attr;
...@@ -643,14 +644,16 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size) ...@@ -643,14 +644,16 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
// Remove all refid's for this node // Remove all refid's for this node
pwr_tNid nid = msg->Items[0].sevid.nid; pwr_tNid nid = msg->Items[0].sevid.nid;
pwr_tStatus sts; pwr_tStatus sts;
sev_sRefid *rp = (sev_sRefid *)tree_Minimum(&sts, m_refid);
sev_sRefid *succ_rp; sev_sRefid *succ_rp;
thread_MutexLock(&m_refid_mutex);
sev_sRefid *rp = (sev_sRefid *)tree_Minimum(&sts, m_refid);
while ( rp) { while ( rp) {
succ_rp = (sev_sRefid *)tree_Successor(&sts, m_refid, rp); succ_rp = (sev_sRefid *)tree_Successor(&sts, m_refid, rp);
if ( rp->id.nid == nid) if ( rp->id.nid == nid)
tree_Remove( &sts, m_refid, &rp->id); tree_Remove( &sts, m_refid, &rp->id);
rp = succ_rp; rp = succ_rp;
} }
thread_MutexUnlock(&m_refid_mutex);
for ( int i = 0; i < item_cnt; i++) { for ( int i = 0; i < item_cnt; i++) {
if ( msg->Items[i].attrnum > 0) { if ( msg->Items[i].attrnum > 0) {
...@@ -778,8 +781,10 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size) ...@@ -778,8 +781,10 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
sev_sRefid *rp; sev_sRefid *rp;
rk = buffP->sevid; rk = buffP->sevid;
thread_MutexLock(&m_refid_mutex);
rp = (sev_sRefid *) tree_Insert(&sts, m_refid, &rk); rp = (sev_sRefid *) tree_Insert(&sts, m_refid, &rk);
rp->idx = idx; rp->idx = idx;
thread_MutexUnlock(&m_refid_mutex);
} }
int numberOfAttributes = buffP->attrnum; int numberOfAttributes = buffP->attrnum;
...@@ -821,8 +826,10 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size) ...@@ -821,8 +826,10 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
sev_sRefid *rp; sev_sRefid *rp;
rk = msg->Items[i].sevid; rk = msg->Items[i].sevid;
thread_MutexLock(&m_refid_mutex);
rp = (sev_sRefid *) tree_Insert(&sts, m_refid, &rk); rp = (sev_sRefid *) tree_Insert(&sts, m_refid, &rk);
rp->idx = idx; rp->idx = idx;
thread_MutexUnlock(&m_refid_mutex);
} }
} }
else { else {
...@@ -874,7 +881,10 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size, ...@@ -874,7 +881,10 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size,
sev_sRefid *rp; sev_sRefid *rp;
pwr_tRefId rk = dp->sevid; pwr_tRefId rk = dp->sevid;
thread_MutexLock(&m_refid_mutex);
rp = (sev_sRefid *) tree_Find(&sts, m_refid, &rk); rp = (sev_sRefid *) tree_Find(&sts, m_refid, &rk);
thread_MutexUnlock(&m_refid_mutex);
if ( !rp) { if ( !rp) {
dp = (sev_sHistData *)((char *)dp + sizeof( *dp) - sizeof(dp->data) + dp->size); dp = (sev_sHistData *)((char *)dp + sizeof( *dp) - sizeof(dp->data) + dp->size);
continue; continue;
...@@ -1449,7 +1459,9 @@ void *sev_server::receive_histdata_thread( void *arg) ...@@ -1449,7 +1459,9 @@ void *sev_server::receive_histdata_thread( void *arg)
sev_sRefid *rp; sev_sRefid *rp;
pwr_tRefId rk = dp->sevid; pwr_tRefId rk = dp->sevid;
thread_MutexLock(&sev->m_refid_mutex);
rp = (sev_sRefid *) tree_Find(&sts, sev->m_refid, &rk); rp = (sev_sRefid *) tree_Find(&sts, sev->m_refid, &rk);
thread_MutexUnlock(&sev->m_refid_mutex);
if ( !rp) { if ( !rp) {
dp = (sev_sHistData *)((char *)dp + sizeof( *dp) - sizeof(dp->data) + dp->size); dp = (sev_sHistData *)((char *)dp + sizeof( *dp) - sizeof(dp->data) + dp->size);
continue; continue;
......
...@@ -123,6 +123,7 @@ class sev_server { ...@@ -123,6 +123,7 @@ class sev_server {
pwr_tStatus m_server_status; pwr_tStatus m_server_status;
vector<sev_node> m_nodes; vector<sev_node> m_nodes;
tree_sTable *m_refid; tree_sTable *m_refid;
thread_sMutex m_refid_mutex;
unsigned int m_msg_id; unsigned int m_msg_id;
sev_db *m_db; sev_db *m_db;
int m_noneth; int m_noneth;
......
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