Commit 1ff96d07 authored by Marco Bartolini's avatar Marco Bartolini
Browse files

ennesimo tentativo di riprendersi da MalformedXMLError

parent 6edb4a43
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ class CustomLoggerImpl: public virtual baci::CharacteristicComponentImpl,
        virtual void emitExceptionLog();
        virtual void flush() throw (CORBA::SystemException);
        void writeLoggingQueue(bool age_check=true); //invoked by writer thread
        void handle_xml_error();
    private:
        void _open_log_file(bool custom, const char* base_path, const char* filename)
                                throw (CORBA::SystemException, ManagementErrors::CustomLoggerIOErrorEx);
+21 −2
Original line number Diff line number Diff line
@@ -295,6 +295,7 @@ void
CustomLoggerImpl::flush() throw (CORBA::SystemException)
{
    maci::ContainerImpl::getLoggerProxy()->flush();
    writeLoggingQueue();
};

void 
@@ -522,6 +523,25 @@ CustomLoggerImpl::writeLoggingQueue(bool age_check)
            };
};

void
CustomLoggerImpl::handle_xml_error()
{
    baci::ThreadSyncGuard guard(&_log_queue_mutex);
    //suspend logging thread
    _writer->suspend();
    //empty ACS log queue
    maci::ContainerImpl::getLoggerProxy()->flush();
    //empty CUSTOM log queue
    while(!_log_queue.empty()){
        _log_queue.pop();
    }
    //reinitialize EXPAT parser
    free_log_parsing(log_parser);
    log_parser = init_log_parsing();
    //resume writer thread
    _writer->resume();
};

CustomStructuredPushConsumer::CustomStructuredPushConsumer(CustomLoggerImpl* logger) : 
    logger_(logger)
{
@@ -593,8 +613,7 @@ void CustomStructuredPushConsumer::push_structured_event (const CosNotification:
                logger_->handle(lr);
            }
    }catch(const MalformedXMLError& mxe){
        free_log_parsing(logger_->log_parser);
        logger_->log_parser = init_log_parsing();
        logger_->handle_xml_error();
    }
};

+2 −1
Original line number Diff line number Diff line
@@ -279,7 +279,8 @@ get_log_record(XML_Parser log_parser, const char *xml_text)
        std::stringstream msg;
        msg << "CustomLoggerMalformedXMLError: ";
        msg << XML_ErrorString(XML_GetErrorCode(log_parser));
        msg << " (" << xml_string.c_str() << ")";
        // Commenting the following line we loose the error message
        //msg << " (" << xml_string.c_str() << ")";
        //log_record->xml_text.assign(msg.str().c_str());
        //log_record->xml_text.assign("CustomLoggerMalformedXMLError");
        ACE_ERROR ((LM_ERROR, msg.str().c_str() ));