Menu

#93 Debug level changeable during runtime

ver 1.2.x
closed-fixed
core (30)
5
2007-07-18
2007-05-30
No

The proposed patch allows to change the debug level during runtime using the command:

openserctl unixsock debug <new level>

Just to get the current debug level, use the command:

openserctl unixsock debug

The feature is implemented by putting the debug level into the shared memory. The type of the global variable "debug" has been changed from int to a pointer to int.

This patch also has some improvements of the logging subsystem in the case when log_stderr logging is used:
1. Timestamp of each message is printed in the header.
2. The level of each log message is printed in the header.
3. C library functions fprintf, vfprintf and fflush are no longer used. The problem with these functions was that sometimes log messages from other openser processes were printed between a header and a body of a log message. If a lot of log messages are printed at the same time from different processes then this causes a hardly readable mess. The solution is to use our own buffer in dprint.c to construct the full log message, then print it as a whole thing using the write system call.

Discussion

  • Anatoly Pidruchny

    Changeable debug level patch

     
  • Bogdan-Andrei Iancu

    Logged In: YES
    user_id=1275325
    Originator: NO

    Hi Anatoly,

    I will review and integrate it with some idea I have regarding the debug parameter.

    Thanks and regards,
    Bogdan

     
  • Bogdan-Andrei Iancu

    • assigned_to: nobody --> bogdan_iancu
     
  • Bogdan-Andrei Iancu

    • status: open --> open-accepted
     
  • Bogdan-Andrei Iancu

    Logged In: YES
    user_id=1275325
    Originator: NO

    Hi Anatoly,

    I commited the patch on SVN with the following notes:
    - extended to enable/disable at compile time the configurable debug level.
    - proper MI integration
    - extension for dprint still not commited - I want to get a closer look and see the impact of it.

    Question: what is the purpose of :
    debug_init = *debug;
    debug = &debug_init;

    at shutdown? I understand that you keep the value and move the pointer to the local variable, but why?

    Regards,
    Bogdan

     
  • Anatoly Pidruchny

    Logged In: YES
    user_id=1759384
    Originator: YES

    Hi Bogdan,

    it was done a long time ago, but I as far as I remember, the code to move the debug pointer to the local variable at shutdown was added to fix a crash during shutdown. I can not tell for sure if OpenSER will crash during shutdown without these lines, but we have these lines, we do not have crashes during shutdown, and so I included them into the patch. Since I can not tell for sure that these lines are really necessary, you can skip them when you apply the patch to the SVN and then we will see how it goes. Have you included these lines when you applied the patch to the SVN?

    Regards,
    Anatoly

     
  • Bogdan-Andrei Iancu

    Logged In: YES
    user_id=1275325
    Originator: NO

    Got it - the problem is the debug pointer may be used after the shared memory is destroyed. That is the cause of the crash you were refering at.
    I made a 100% safe approach by switching the debug pointer just befor destroing the shm memory, so it will never get to crash.

    In the next days I will send on the lists an email regarding a bit of refurbishing of the logging system/style and then we will see what to do with the pending drpint() part.

    Regards,
    Bogdan

     
  • Anatoly Pidruchny

    Logged In: YES
    user_id=1759384
    Originator: YES

    Bogdan, you got it 100% right. Please also take a look at the proposed dprint improvements. They are only for the log_stderr mode, but hopefully they will be useful in the context of the whole logging system refurbishing.

    Regards,
    Anatoly

     
  • Bogdan-Andrei Iancu

    Logged In: YES
    user_id=1275325
    Originator: NO

    Hi Anatoly,

    the complete functionality of the patch is now on SVN.

    Thanks and regards,
    Bogdan

     
  • Bogdan-Andrei Iancu

    • status: open-accepted --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB