Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-104

ODBCAppender::close does not check if appender is already closed

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments


    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.7
    • Fix Version/s: 0.10.0
    • Component/s: Appender
    • Labels:


      [prev in list] [next in list] [prev in thread] [next in thread]

      List: log4cxx-dev
      Subject: Changes of ODBCAppender's close() method
      From: Christian Adams <christian.adams () comlet ! de>
      Date: 2005-09-28 7:19:27
      Message-ID: 433A43FF.5020600 () comlet ! de
      [Download message RAW]


      I had to do these changes to the methode close() from the ODBCAppender:
      Would you like to include them in your code?

      virtual void close()
      if (this->closed) <<<<<<<<<<<<<<<<<<

      { <<<<<<<<<<<<<<<<<< return; <<<<<<<<<<<<<<<<<< }



      { flushBuffer(); }

      catch (SQLException& e)

      { errorHandler->error(_T("Error closing connection"), e, log4cxx::spi::ErrorCode::GENERIC_FAILURE); }

      if (connection != SQL_NULL_HDBC)

      { SQLDisconnect(connection); SQLFreeHandle(SQL_HANDLE_DBC, connection); connection = SQL_NULL_HDBC; <<<<<<<<<<<<<<<<<< }

      if (env != SQL_NULL_HENV)

      { SQLFreeHandle(SQL_HANDLE_ENV, env); env = SQL_NULL_HENV; <<<<<<<<<<<<<<<<<< }

      this->closed = true;

      My reasons:
      My application crashes if I log into an postgres 8.0 DB while the
      destructor destroys the Appenders.
      (exactly at SQLFreeHandle(SQL_HANDLE_DBC, connection); in close() called
      from finalize() called from ~ODBCAppender().)
      To avoid this crash (which only happens with postgres, not with mysql),
      I have to close the appenders before their destructor is called. I do
      this by removing all appenders from all loggers when my last
      logger-wrapper will be destroyed. And there it can happen that close()
      of one appender will be called twice (if two different loggers have the
      same appender).
      And than it is important to block this second call.

      If all that is not postgres' error but mine or i can solve this problem
      otherwise or someone has the same problem please answer!!

      Thanks for reading

      Christian Adams

      [prev in list] [next in list] [prev in thread] [next in thread]

      Configure | About MARC | Support MARC | Got a list to add? | Sponsored by 10East and KoreLogic




            • Assignee:
              carnold@apache.org Curt Arnold
              carnold@apache.org Curt Arnold


              • Created:

                Issue deployment