Fix indentation and style issues in fmAPI
Several indentation issues were solved, also some style was applied to improve code's readability. No funcionality changes were done. Story: 2006425 Task: 36322 Change-Id: Ie3339ed10254a053a2e26397337c45dfa2d552bd Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
This commit is contained in:
parent
96f4179575
commit
f9ba635bfd
@ -51,21 +51,26 @@ static bool m_connected = false;
|
|||||||
static bool m_thread = false;
|
static bool m_thread = false;
|
||||||
|
|
||||||
typedef std::list<fm_buff_t> FmRequestListT;
|
typedef std::list<fm_buff_t> FmRequestListT;
|
||||||
|
|
||||||
|
|
||||||
static FmRequestListT & GetListOfFmRequests() {
|
static FmRequestListT & GetListOfFmRequests() {
|
||||||
static FmRequestListT reqs;
|
static FmRequestListT reqs;
|
||||||
return reqs;
|
return reqs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static CFmMutex & getListMutex() {
|
static CFmMutex & getListMutex() {
|
||||||
static CFmMutex *m = new CFmMutex;
|
static CFmMutex *m = new CFmMutex;
|
||||||
return *m;
|
return *m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static CFmMutex & getThreadMutex() {
|
static CFmMutex & getThreadMutex() {
|
||||||
static CFmMutex *m = new CFmMutex;
|
static CFmMutex *m = new CFmMutex;
|
||||||
return *m;
|
return *m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CFmMutex & getAPIMutex() {
|
CFmMutex & getAPIMutex() {
|
||||||
static pthread_mutex_t ml = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
static pthread_mutex_t ml = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
||||||
static CFmMutex *m = NULL;
|
static CFmMutex *m = NULL;
|
||||||
@ -77,16 +82,19 @@ CFmMutex & getAPIMutex(){
|
|||||||
return *m;
|
return *m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void enqueue(fm_buff_t &req) {
|
static void enqueue(fm_buff_t &req) {
|
||||||
CFmMutexGuard m(getListMutex());
|
CFmMutexGuard m(getListMutex());
|
||||||
GetListOfFmRequests().push_back(req);
|
GetListOfFmRequests().push_back(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool dequeue(fm_buff_t &req) {
|
static bool dequeue(fm_buff_t &req) {
|
||||||
CFmMutexGuard m(getListMutex());
|
CFmMutexGuard m(getListMutex());
|
||||||
if (GetListOfFmRequests().size() == 0) {
|
if (GetListOfFmRequests().size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FmRequestListT::iterator it = GetListOfFmRequests().begin();
|
FmRequestListT::iterator it = GetListOfFmRequests().begin();
|
||||||
req.clear();
|
req.clear();
|
||||||
req = (*it);
|
req = (*it);
|
||||||
@ -94,6 +102,7 @@ static bool dequeue(fm_buff_t &req){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool fm_lib_reconnect() {
|
static bool fm_lib_reconnect() {
|
||||||
char addr[INET6_ADDRSTRLEN];
|
char addr[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
@ -140,6 +149,7 @@ static bool fm_lib_reconnect() {
|
|||||||
return (m_connected);
|
return (m_connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EFmErrorT fm_msg_utils_prep_requet_msg(fm_buff_t &buff,
|
EFmErrorT fm_msg_utils_prep_requet_msg(fm_buff_t &buff,
|
||||||
EFmMsgActionsT act,
|
EFmMsgActionsT act,
|
||||||
const void * data,
|
const void * data,
|
||||||
@ -160,6 +170,7 @@ EFmErrorT fm_msg_utils_prep_requet_msg(fm_buff_t &buff,
|
|||||||
return FM_ERR_OK;
|
return FM_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void fmApiJobHandlerThread(void *context) {
|
static void fmApiJobHandlerThread(void *context) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -181,8 +192,7 @@ static void fmApiJobHandlerThread(void *context){
|
|||||||
fm_log_response(buff, in_buff, true);
|
fm_log_response(buff, in_buff, true);
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fm_log_response(buff, in_buff);
|
fm_log_response(buff, in_buff);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -198,20 +208,21 @@ static void fmApiJobHandlerThread(void *context){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool fm_lib_thread() {
|
static bool fm_lib_thread() {
|
||||||
CFmMutexGuard m(getThreadMutex());
|
CFmMutexGuard m(getThreadMutex());
|
||||||
if (!m_thread) {
|
if (!m_thread) {
|
||||||
FM_INFO_LOG("Creating thread");
|
FM_INFO_LOG("Creating thread");
|
||||||
if (!fmCreateThread(fmApiJobHandlerThread, NULL)) {
|
if (!fmCreateThread(fmApiJobHandlerThread, NULL)) {
|
||||||
FM_ERROR_LOG("Fail to create API job thread");
|
FM_ERROR_LOG("Fail to create API job thread");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
m_thread = true;
|
m_thread = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m_thread;
|
return m_thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static EFmErrorT fm_check_thread_pending_request() {
|
static EFmErrorT fm_check_thread_pending_request() {
|
||||||
CFmMutexGuard m(getThreadMutex());
|
CFmMutexGuard m(getThreadMutex());
|
||||||
if (m_thread) {
|
if (m_thread) {
|
||||||
@ -233,6 +244,7 @@ EFmErrorT fm_init_lib() {
|
|||||||
return FM_ERR_OK;
|
return FM_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EFmErrorT fm_set_fault(const SFmAlarmDataT *alarm,
|
EFmErrorT fm_set_fault(const SFmAlarmDataT *alarm,
|
||||||
fm_uuid_t *uuid) {
|
fm_uuid_t *uuid) {
|
||||||
|
|
||||||
@ -263,6 +275,7 @@ EFmErrorT fm_set_fault(const SFmAlarmDataT *alarm,
|
|||||||
return FM_ERR_OK;
|
return FM_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EFmErrorT fm_clear_fault(AlarmFilter *filter) {
|
EFmErrorT fm_clear_fault(AlarmFilter *filter) {
|
||||||
|
|
||||||
CFmMutexGuard m(getAPIMutex());
|
CFmMutexGuard m(getAPIMutex());
|
||||||
@ -287,6 +300,7 @@ EFmErrorT fm_clear_fault(AlarmFilter *filter){
|
|||||||
return FM_ERR_OK;
|
return FM_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EFmErrorT fm_clear_all(fm_ent_inst_t *inst_id) {
|
EFmErrorT fm_clear_all(fm_ent_inst_t *inst_id) {
|
||||||
|
|
||||||
CFmMutexGuard m(getAPIMutex());
|
CFmMutexGuard m(getAPIMutex());
|
||||||
@ -343,8 +357,10 @@ EFmErrorT fm_get_fault(AlarmFilter *filter, SFmAlarmDataT *alarm ){
|
|||||||
return FM_ERR_OK;
|
return FM_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EFmErrorT fm_get_faults(fm_ent_inst_t *inst_id,
|
EFmErrorT fm_get_faults(fm_ent_inst_t *inst_id,
|
||||||
SFmAlarmDataT *alarm, unsigned int *max_alarms_to_get) {
|
SFmAlarmDataT *alarm,
|
||||||
|
unsigned int *max_alarms_to_get) {
|
||||||
|
|
||||||
CFmMutexGuard m(getAPIMutex());
|
CFmMutexGuard m(getAPIMutex());
|
||||||
if (!fm_lib_reconnect()) return FM_ERR_NOCONNECT;
|
if (!fm_lib_reconnect()) return FM_ERR_NOCONNECT;
|
||||||
@ -396,7 +412,9 @@ EFmErrorT fm_get_faults(fm_ent_inst_t *inst_id,
|
|||||||
return FM_ERR_OK;
|
return FM_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFmErrorT fm_get_faults_by_id(fm_alarm_id *alarm_id, SFmAlarmDataT *alarm,
|
|
||||||
|
EFmErrorT fm_get_faults_by_id(fm_alarm_id *alarm_id,
|
||||||
|
SFmAlarmDataT *alarm,
|
||||||
unsigned int *max_alarms_to_get) {
|
unsigned int *max_alarms_to_get) {
|
||||||
|
|
||||||
CFmMutexGuard m(getAPIMutex());
|
CFmMutexGuard m(getAPIMutex());
|
||||||
@ -449,6 +467,7 @@ EFmErrorT fm_get_faults_by_id(fm_alarm_id *alarm_id, SFmAlarmDataT *alarm,
|
|||||||
return FM_ERR_OK;
|
return FM_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* APIs that enqueue the request and return ok for acknowledgment.
|
* APIs that enqueue the request and return ok for acknowledgment.
|
||||||
* A backgroup thread will pick up the request and send it to the FM Manager
|
* A backgroup thread will pick up the request and send it to the FM Manager
|
||||||
@ -477,6 +496,7 @@ EFmErrorT fm_set_fault_async(const SFmAlarmDataT *alarm, fm_uuid_t *uuid){
|
|||||||
return FM_ERR_OK;
|
return FM_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EFmErrorT fm_clear_fault_async(AlarmFilter *filter) {
|
EFmErrorT fm_clear_fault_async(AlarmFilter *filter) {
|
||||||
|
|
||||||
if ( !fm_lib_thread()) return FM_ERR_RESOURCE_UNAVAILABLE;
|
if ( !fm_lib_thread()) return FM_ERR_RESOURCE_UNAVAILABLE;
|
||||||
@ -495,6 +515,7 @@ EFmErrorT fm_clear_fault_async(AlarmFilter *filter){
|
|||||||
return FM_ERR_OK;
|
return FM_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EFmErrorT fm_clear_all_async(fm_ent_inst_t *inst_id) {
|
EFmErrorT fm_clear_all_async(fm_ent_inst_t *inst_id) {
|
||||||
|
|
||||||
if ( !fm_lib_thread()) return FM_ERR_RESOURCE_UNAVAILABLE;
|
if ( !fm_lib_thread()) return FM_ERR_RESOURCE_UNAVAILABLE;
|
||||||
|
@ -187,6 +187,9 @@ typedef struct {
|
|||||||
}AlarmFilter;
|
}AlarmFilter;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* APIs to create, clear and query alarms.
|
||||||
|
*/
|
||||||
EFmErrorT fm_set_fault(const SFmAlarmDataT *alarm, fm_uuid_t *uuid);
|
EFmErrorT fm_set_fault(const SFmAlarmDataT *alarm, fm_uuid_t *uuid);
|
||||||
|
|
||||||
EFmErrorT fm_clear_fault(AlarmFilter *filter);
|
EFmErrorT fm_clear_fault(AlarmFilter *filter);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user