Hi,
ACK , tested
Please re-base before publishing.
-AVM
On 8/4/2016 9:36 AM, Canh Van Truong wrote:
> osaf/services/saf/logsv/lgs/lgs_imm.cc | 52
> +++++++++++++++++-----------------
> 1 files changed, 26 insertions(+), 26 deletions(-)
>
>
> When changing saLogStreamFileName with other attributes, the action
> "closing current log file", "rename", "create new cfg and log file" are
> duplicated. This cause the ER in syslog, because lgsv can not find log
> file when closing secondly. Name of current log file was changed at first
> time.
>
> This patch make lgsv just do above action only once.
>
> diff --git a/osaf/services/saf/logsv/lgs/lgs_imm.cc
> b/osaf/services/saf/logsv/lgs/lgs_imm.cc
> --- a/osaf/services/saf/logsv/lgs/lgs_imm.cc
> +++ b/osaf/services/saf/logsv/lgs/lgs_imm.cc
> @@ -2275,7 +2275,7 @@ static void stream_ccb_apply_modify(cons
> bool new_cfg_file_needed = false;
> struct timespec curtime_tspec;
> std::string fileName;
> - bool modify = false;
> + bool stream_filename_modified = false;
>
> TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId,
> opdata->objectName.value);
>
> @@ -2295,7 +2295,7 @@ static void stream_ccb_apply_modify(cons
>
> if (!strcmp(attribute->attrName, "saLogStreamFileName")) {
> fileName = *((char **)value);
> - modify = true;
> + stream_filename_modified = true;
> } else if (!strcmp(attribute->attrName,
> "saLogStreamMaxLogFileSize")) {
> SaUint64T maxLogFileSize = *((SaUint64T *)value);
> stream->maxLogFileSize = maxLogFileSize;
> @@ -2337,7 +2337,30 @@ static void stream_ccb_apply_modify(cons
> time_t cur_time = curtime_tspec.tv_sec;
> std::string root_path = static_cast<const char
> *>(lgs_cfg_get(LGS_IMM_LOG_ROOT_DIRECTORY));
>
> - if (new_cfg_file_needed) {
> + /* Fix for ticket #1346 */
> + if (stream_filename_modified) {
> + int rc;
> + if ((rc = log_stream_config_change(!LGS_STREAM_CREATE_FILES,
> + root_path, stream, current_logfile_name, &cur_time))
> + != 0) {
> + LOG_ER("log_stream_config_change failed: %d", rc);
> + }
> +
> + stream->fileName = fileName;
> +
> + if ((rc = lgs_create_config_file_h(root_path, stream)) != 0) {
> + LOG_ER("lgs_create_config_file_h failed: %d", rc);
> + }
> +
> + char *current_time = lgs_get_time(&cur_time);
> + stream->logFileCurrent = stream->fileName + "_" + current_time;
> +
> + // Create the new log file based on updated configuration
> + if ((*stream->p_fd = log_file_open(root_path,
> + stream, stream->logFileCurrent, NULL)) == -1)
> + LOG_ER("New log file could not be created for stream:
> %s",
> + stream->name);
> + } else if (new_cfg_file_needed) {
> int rc;
> if ((rc = log_stream_config_change(LGS_STREAM_CREATE_FILES,
> root_path, stream,
> @@ -2347,29 +2370,6 @@ static void stream_ccb_apply_modify(cons
> }
> }
>
> - /* Fix for ticket #1346 */
> - if (modify) {
> - int rc;
> - if ((rc = log_stream_config_change(!LGS_STREAM_CREATE_FILES,
> - root_path, stream, current_logfile_name, &cur_time))
> - != 0) {
> - LOG_ER("log_stream_config_change failed: %d", rc);
> - }
> -
> - stream->fileName = fileName;
> -
> - if ((rc = lgs_create_config_file_h(root_path, stream)) != 0) {
> - LOG_ER("lgs_create_config_file_h failed: %d", rc);
> - }
> -
> - char *current_time = lgs_get_time(&cur_time);
> - stream->logFileCurrent = stream->fileName + "_" + current_time;
> -
> - // Create the new log file based on updated configuration
> - *stream->p_fd = log_file_open(root_path,
> - stream, stream->logFileCurrent, NULL);
> - }
> -
> /* Checkpoint to standby LOG server */
> /* Save time change was done for standby */
> stream->act_last_close_timestamp = cur_time;
------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel