osaf/services/saf/logsv/README | 7 ++- osaf/services/saf/logsv/config/logsv_classes.xml | 14 ++++++ osaf/services/saf/logsv/lgs/lgs.h | 2 + osaf/services/saf/logsv/lgs/lgs_file.c | 45 +++++++++++++----- osaf/services/saf/logsv/lgs/lgs_imm.c | 55 +++++++++++++++++++++-- 5 files changed, 103 insertions(+), 20 deletions(-)
- Make timeouts for file hdl configurable in Log service configuration object diff --git a/osaf/services/saf/logsv/README b/osaf/services/saf/logsv/README --- a/osaf/services/saf/logsv/README +++ b/osaf/services/saf/logsv/README @@ -153,14 +153,17 @@ meaning that all parameters will get the The class defines the following parameters (logsv_classes.xml): -NAME DEFAULT VALUE -saLogRootDirectory /var/log/opensaf/saflog +NAME DEFAULT VALUE COMMENT +saLogRootDirectory $pkglogdir/saflog saLogMaxLogrecsize 1024 saLogStreamSystemHighLimit 0 saLogStreamSystemLowLimit 0 saLogAppHighLimit 0 saLogAppLowLimit 0 saLogMaxApplicationStreams 64 +logFileHdlTimeoutMs 500 File I/O timeout (see file.c) +logFileHdlRecoveryTimeoutS 600 File I/O thread timeout (see + file.c) All the above parameters except saLogRootDirectory has a default value set in the class definition (see logsv_classes.xml). The value for parameter diff --git a/osaf/services/saf/logsv/config/logsv_classes.xml b/osaf/services/saf/logsv/config/logsv_classes.xml --- a/osaf/services/saf/logsv/config/logsv_classes.xml +++ b/osaf/services/saf/logsv/config/logsv_classes.xml @@ -221,5 +221,19 @@ <flag>SA_WRITABLE</flag> <default-value>64</default-value> </attr> + <attr> + <name>logFileHdlTimeoutMs</name> + <type>SA_UINT32_T</type> + <category>SA_CONFIG</category> + <flag>SA_WRITABLE</flag> + <default-value>500</default-value> + </attr> + <attr> + <name>logFileHdlRecoveryTimeoutS</name> + <type>SA_UINT32_T</type> + <category>SA_CONFIG</category> + <flag>SA_WRITABLE</flag> + <default-value>600</default-value> + </attr> </class> </imm:IMM-contents> diff --git a/osaf/services/saf/logsv/lgs/lgs.h b/osaf/services/saf/logsv/lgs/lgs.h --- a/osaf/services/saf/logsv/lgs/lgs.h +++ b/osaf/services/saf/logsv/lgs/lgs.h @@ -89,6 +89,8 @@ typedef enum { LGS_IMM_LOG_STREAM_APP_HIGH_LIMIT, LGS_IMM_LOG_STREAM_APP_LOW_LIMIT, LGS_IMM_LOG_MAX_APPLICATION_STREAMS, + LGS_IMM_FILEHDL_TIMEOUT, + LGS_IMM_FILEHDL_RECOVERY_TIMEOUT, LGS_IMM_LOG_NUMBER_OF_PARAMS, LGS_IMM_LOG_OPENSAFLOGCONFIG_CLASS_EXIST, diff --git a/osaf/services/saf/logsv/lgs/lgs_file.c b/osaf/services/saf/logsv/lgs/lgs_file.c --- a/osaf/services/saf/logsv/lgs/lgs_file.c +++ b/osaf/services/saf/logsv/lgs/lgs_file.c @@ -32,18 +32,20 @@ #include <time.h> #include <ncsgl_defs.h> +#include "lgs.h" #include "osaf_utility.h" -/* Max time to wait for file thread to finish */ -#define MAX_WAITTIME_ms 500 /* ms */ -/* Max time to wait for hanging file thread before recovery */ -#define MAX_RECOVERYTIME_s 600 /* s */ #define GETTIME(x) osafassert(clock_gettime(CLOCK_REALTIME, &x) == 0); static pthread_mutex_t lgs_ftcom_mutex; /* For locking communication */ static pthread_cond_t request_cv; /* File thread waiting for request */ static pthread_cond_t answer_cv; /* API waiting for answer (timed) */ +/* Max time to wait for file thread to finish */ +static SaUint32T max_waittime_ms = 500; +/* Max time to wait for hanging file thread before recovery */ +static SaUint32T max_recoverytime_s = 600; + struct file_communicate { bool request_f; /* True if pending request */ bool answer_f; /* True if pending answer */ @@ -123,7 +125,7 @@ static void ft_check_recovery(void) TRACE("dtime_ms = %ld",dtime_ms); - if (dtime_ms >= (MAX_RECOVERYTIME_s * 1000)) { + if (dtime_ms >= (max_recoverytime_s * 1000)) { TRACE("Recovering file thread"); remove_file_thread(); rc = start_file_thread(); @@ -353,6 +355,16 @@ uint32_t lgs_file_init(void) TRACE_ENTER(); + /* Initiate timeouts from Log service IMM configuration object */ + max_waittime_ms = *(SaUint32T*) lgs_imm_logconf_get( + LGS_IMM_FILEHDL_TIMEOUT, NULL); + TRACE("max_waittime_ms = %d",max_waittime_ms); + /* Max time to wait for hanging file thread before recovery */ + max_recoverytime_s = *(SaUint32T*) lgs_imm_logconf_get( + LGS_IMM_FILEHDL_RECOVERY_TIMEOUT, NULL); + TRACE("max_recoverytime_s = %d",max_recoverytime_s); + + if (start_file_thread() != 0) { rc = NCSCC_RC_FAILURE; } @@ -415,7 +427,7 @@ lgsf_retcode_t log_file_api(lgsf_apipar_ /* Wait for an answer */ GETTIME(m_start_time); /* Used for TRACE of print of time to answer */ - get_timeout_time(&timeout_time, MAX_WAITTIME_ms); + get_timeout_time(&timeout_time, max_waittime_ms); while (lgs_com_data.answer_f == false) { rc = pthread_cond_timedwait( @@ -434,6 +446,13 @@ lgsf_retcode_t log_file_api(lgsf_apipar_ } } + /* Measure answer time for TRACE */ + GETTIME(m_end_time); + stime_ms = (m_start_time.tv_sec * 1000) + (m_start_time.tv_nsec / 1000000); + etime_ms = (m_end_time.tv_sec * 1000) + (m_end_time.tv_nsec / 1000000); + dtime_ms = etime_ms - stime_ms; + TRACE("Time waited for answer %ld ms",dtime_ms); + /* We have an answer * NOTE! * The out-data buffer 'par_out' must be big enough to handle the @@ -443,13 +462,6 @@ lgsf_retcode_t log_file_api(lgsf_apipar_ apipar_in->hdl_ret_code_out = lgs_com_data.return_code; memcpy(apipar_in->data_out, lgs_com_data.outdata_ptr, lgs_com_data.outdata_size); - /* Measure answer time for TRACE */ - GETTIME(m_end_time); - stime_ms = (m_start_time.tv_sec * 1000) + (m_start_time.tv_nsec / 1000000); - etime_ms = (m_end_time.tv_sec * 1000) + (m_end_time.tv_nsec / 1000000); - dtime_ms = etime_ms - stime_ms; - TRACE("Time waited for answer %ld ms",dtime_ms); - /* Prepare to take a new answer */ lgs_com_data.answer_f = false; lgs_com_data.return_code = LGSF_NORETC; @@ -471,6 +483,13 @@ api_exit: */ ft_check_recovery(); + /* Measure answer time for TRACE */ + GETTIME(m_end_time); + stime_ms = (m_start_time.tv_sec * 1000) + (m_start_time.tv_nsec / 1000000); + etime_ms = (m_end_time.tv_sec * 1000) + (m_end_time.tv_nsec / 1000000); + dtime_ms = etime_ms - stime_ms; + TRACE("Time leaving API %ld ms",dtime_ms); + TRACE_LEAVE(); return api_rc; } diff --git a/osaf/services/saf/logsv/lgs/lgs_imm.c b/osaf/services/saf/logsv/lgs/lgs_imm.c --- a/osaf/services/saf/logsv/lgs/lgs_imm.c +++ b/osaf/services/saf/logsv/lgs/lgs_imm.c @@ -53,6 +53,8 @@ typedef struct { SaUint32T logStreamAppHighLimit; SaUint32T logStreamAppLowLimit; SaUint32T logMaxApplicationStreams; + SaUint32T logFileHdlTimeoutMs; + SaUint32T logFileHdlRecoveryTimeoutS; /* --- end correspond to IMM Class --- */ bool logInitiated; @@ -65,6 +67,8 @@ typedef struct { bool logStreamAppHighLimit_noteflag; bool logStreamAppLowLimit_noteflag; bool logMaxApplicationStreams_noteflag; + bool logFileHdlTimeoutMs_noteflag; + bool logFileHdlRecoveryTimeoutS_noteflag; } lgs_conf_t; /* DATA DECLARATIONS @@ -82,7 +86,14 @@ static lgs_conf_t _lgs_conf = { .logStreamAppHighLimit = 0, .logStreamAppLowLimit = 0, .logMaxApplicationStreams = 64, + .logFileHdlTimeoutMs = 500, + .logFileHdlRecoveryTimeoutS = 600, + /* + * For the following flags, true means that no external configuration + * exists and the corresponding attributes hard-coded default value is used + * See function lgs_imm_logconf_get() for more info. + */ .logInitiated = false, .OpenSafLogConfig_class_exist = false, @@ -92,7 +103,13 @@ static lgs_conf_t _lgs_conf = { .logStreamSystemLowLimit_noteflag = false, .logStreamAppHighLimit_noteflag = false, .logStreamAppLowLimit_noteflag = false, - .logMaxApplicationStreams_noteflag = false + .logMaxApplicationStreams_noteflag = false, + /* + * The following attributes cannot be configured in the config file + * Will be set to false if the attribute exists in the IMM config object + */ + .logFileHdlTimeoutMs_noteflag = true, + .logFileHdlRecoveryTimeoutS_noteflag = true }; static lgs_conf_t *lgs_conf = &_lgs_conf; @@ -472,6 +489,14 @@ static SaAisErrorT config_ccb_completed_ LOG_NO("%s cannot be changed", attribute->attrName); rc = SA_AIS_ERR_FAILED_OPERATION; goto done; + } else if (!strcmp(attribute->attrName, "logFileHdlTimeoutMs")) { + LOG_NO("%s cannot be changed", attribute->attrName); + rc = SA_AIS_ERR_FAILED_OPERATION; + goto done; + } else if (!strcmp(attribute->attrName, "logFileHdlRecoveryTimeoutS")) { + LOG_NO("%s cannot be changed", attribute->attrName); + rc = SA_AIS_ERR_FAILED_OPERATION; + goto done; } else { LOG_NO("attribute %s not recognized", attribute->attrName); rc = SA_AIS_ERR_FAILED_OPERATION; @@ -1489,14 +1514,24 @@ static SaAisErrorT read_logsv_config_obj lgsConf->logMaxApplicationStreams = *((SaUint32T *) value); param_cnt++; TRACE("logMaxApplicationStreams: %u", lgsConf->logMaxApplicationStreams); + } else if (!strcmp(attribute->attrName, "logFileHdlTimeoutMs")) { + lgsConf->logFileHdlTimeoutMs = *((SaUint32T *) value); + lgsConf->logMaxLogrecsize_noteflag = false; + param_cnt++; + TRACE("logFileHdlTimeoutMs: %u", lgsConf->logFileHdlTimeoutMs); + } else if (!strcmp(attribute->attrName, "logFileHdlRecoveryTimeoutS")) { + lgsConf->logFileHdlRecoveryTimeoutS = *((SaUint32T *) value); + lgsConf->logMaxLogrecsize_noteflag = false; + param_cnt++; + TRACE("logFileHdlRecoveryTimeoutS: %u", lgsConf->logFileHdlRecoveryTimeoutS); } } - /* Check if missing parameters */ + /* Check if missing attributes. Default value will be used if attribute is + * missing. + */ if (param_cnt != LGS_IMM_LOG_NUMBER_OF_PARAMS) { - lgsConf->OpenSafLogConfig_class_exist = false; - rc = SA_AIS_ERR_NOT_EXIST; - LOG_ER("read_logsv_configuration(), Parameter error. All parameters could not be read"); + LOG_WA("read_logsv_configuration(). All attributes could not be read"); } done: @@ -1718,6 +1753,16 @@ const void *lgs_imm_logconf_get(lgs_logc *noteflag = lgs_conf->logMaxApplicationStreams_noteflag; } return (SaUint32T *) &lgs_conf->logMaxApplicationStreams; + case LGS_IMM_FILEHDL_TIMEOUT: + if (noteflag != NULL) { + *noteflag = lgs_conf->logFileHdlTimeoutMs_noteflag; + } + return (SaUint32T *) &lgs_conf->logFileHdlTimeoutMs; + case LGS_IMM_FILEHDL_RECOVERY_TIMEOUT: + if (noteflag != NULL) { + *noteflag = lgs_conf->logFileHdlRecoveryTimeoutS_noteflag; + } + return (SaUint32T *) &lgs_conf->logFileHdlRecoveryTimeoutS; case LGS_IMM_LOG_OPENSAFLOGCONFIG_CLASS_EXIST: if (noteflag != NULL) { *noteflag = false; ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel