Hi Canh

Ack

Thanks
Lennart

> -----Original Message-----
> From: Canh Van Truong
> Sent: den 4 augusti 2016 06:06
> To: Vu Minh Nguyen <[email protected]>;
> [email protected]; Lennart Lund <[email protected]>
> Cc: [email protected]
> Subject: [PATCH 1 of 1] log: fix ER in syslog if changing saLogStreamFileName
> and other atrributes[#1887]
> 
>  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);
[Lennart] Does not build, stream->name must be stream->name.c_str()

> +     } 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;

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to