Hi

I saw that this ticket was pushed to opensaf-4.4.x. In this version there is no 
risk of that the log service will be hanging because of slow file i/o so I 
don't think it is needed from 4.4 but maybe it does no harm.

 - Synchronous requests that do file i/o may "hang" for a maximum of 500 ms 
(configurable but default 500 ms) because of slow file i/o.
 - Opening of streams will always succeed even if the file cannot be handled. 
If files could not be created when the stream was opened they will be created 
when writing to the stream.
 - If the asynchronous write request fails to write a log record because of 
file i/o problem SA_AIS_ERR_TRY_AGAIN is reported in the callback function if 
installed. Invoking the callback may be delayed for a maximum of 500 ms (see 
above).
 - There is no delay at all if a new attempt to write is done because of try 
again response and the previous write (or other file i/o) has not yet returned 
(file handling still busy).

/Lennart

> -----Original Message-----
> From: Mathivanan Naickan Palanivelu [mailto:mathi.naic...@oracle.com]
> Sent: den 12 februari 2014 16:58
> To: Hans Feldt
> Cc: Lennart Lund; opensaf-devel@lists.sourceforge.net;
> praveen.malv...@oracle.com
> Subject: Re: [PATCH 1 of 4] osaf: add a new safloginit routine [#720]
> 
> Comments inline:
> 
> ----- hans.fe...@ericsson.com wrote:
> 
> > minor comments inline
> > /Hans
> >
> >
> > On 02/03/2014 10:05 AM, mathi.naic...@oracle.com wrote:
> > >   osaf/tools/saflog/include/saflog.h |   6 +++++
> > >   osaf/tools/saflog/src/saflog.c     |  45
> > +++++++++++++++++++++++++++++--------
> > >   2 files changed, 41 insertions(+), 10 deletions(-)
> > >
> > >
> > > There can be situations during switchover/failover when clients of
> > LOG can
> > > be blocked because LOG is busy doing file i/o. One additional reason
> > is that
> > > LOG clients use the common saflog routine that when called for the
> > > first time, does an initialize() and streamopen() both of which are
> > > synchronous calls and if streamopen() fails, saflog does a
> > logfinalize()
> > > which is also a synchronous calls. So in a worst case scenario,
> > when
> > > saflog() is called by a standby process that is becoming active,
> > then saflog()
> > > can get blocked for <=30 seconds before it returns
> > > back to the caller, i.e. mds send timeout of 10 seconds X 3
> > synchronous
> > > APIs. This patch adds a separate safloginit() routine that can be
> > used by
> > > saflog() users such that it is called much before during their
> > lifetime than
> > > during role change.
> > >
> > > diff --git a/osaf/tools/saflog/include/saflog.h
> > b/osaf/tools/saflog/include/saflog.h
> > > --- a/osaf/tools/saflog/include/saflog.h
> > > +++ b/osaf/tools/saflog/include/saflog.h
> > > @@ -19,6 +19,7 @@
> > >   #define SAFLOG_H
> > >
> > >   #include <saAis.h>
> > > +#include <saLog.h>
> > >
> > >   #ifdef __cplusplus
> > >   extern "C" {
> > > @@ -33,6 +34,11 @@ extern "C" {
> > >   extern void saflog(int priority, const SaNameT *logSvcUsrName,
> > >           const char *format, ...) __attribute__ ((format(printf, 3, 4)));
> > >
> > > +extern int gl_initialized;
> > > +extern SaLogStreamHandleT gl_logStreamHandle;
> > > +extern SaLogHandleT gl_logHandle;
> > > +
> > > +extern void saflogInit(void);
> > >   #ifdef __cplusplus
> > >   }
> > >   #endif
> > > diff --git a/osaf/tools/saflog/src/saflog.c
> > b/osaf/tools/saflog/src/saflog.c
> > > --- a/osaf/tools/saflog/src/saflog.c
> > > +++ b/osaf/tools/saflog/src/saflog.c
> > > @@ -19,14 +19,40 @@
> > >   #include <syslog.h>
> > >   #include <stdarg.h>
> > >   #include <unistd.h>
> > > -#include <saLog.h>
> > >   #include <saflog.h>
> > >
> > > +int gl_initialized;
> > > +SaLogStreamHandleT gl_logStreamHandle;
> > > +SaLogHandleT gl_logHandle;
> >
> > why not static?
> >
> 
> I shall do that. This patch was toned down from another patch that already
> had split saflog().
> 
> > > +
> > > +void saflogInit(void)
> >
> > please call it saflog_init, this is C
> >
> 
> Okay, But you would know that this code is already full of hungarian notation.
> I wanted to stay consistent with this part of the code.
> 
> Will push with these two changes.
> 
> - Mathi.
> 
> > > +{
> > > + SaAisErrorT error;
> > > +
> > > + if (!gl_initialized) {
> > > +         SaVersionT logVersion = { 'A', 2, 1 };
> > > +         SaNameT stream_name = {.value =
> SA_LOG_STREAM_SYSTEM, .length =
> > sizeof(SA_LOG_STREAM_SYSTEM)};
> > > +
> > > +         error = saLogInitialize(&gl_logHandle, NULL, &logVersion);
> > > +         if (error != SA_AIS_OK) {
> > > +                 syslog(LOG_INFO, "saflogInit: saLogInitialize FAILED:
> %u",
> > error);
> > > +                 return;
> > > +         }
> > > +
> > > +         error = saLogStreamOpen_2(gl_logHandle, &stream_name,
> NULL, 0,
> > SA_TIME_ONE_SECOND, &gl_logStreamHandle);
> > > +         if (error != SA_AIS_OK) {
> > > +                 syslog(LOG_INFO, "saflogInit: saLogStreamOpen_2
> FAILED: %u",
> > error);
> > > +                 if (saLogFinalize(gl_logHandle) != SA_AIS_OK)
> > > +                         syslog(LOG_INFO, "saflogInit: saLogFinalize
> FAILED: %u",
> > error);
> > > +                 return;
> > > +         }
> > > +         gl_initialized = 1;
> > > + }
> > > +}
> > > +
> > >   void saflog(int priority, const SaNameT *logSvcUsrName, const char
> > *format, ...)
> > >   {
> > >           SaAisErrorT error;
> > > - static int initialized;
> > > - static SaLogStreamHandleT logStreamHandle;
> > >           SaLogRecordT logRecord;
> > >           SaLogBufferT logBuffer;
> > >           va_list ap;
> > > @@ -36,25 +62,24 @@ void saflog(int priority, const SaNameT
> > >           logBuffer.logBufSize = vsnprintf(str, sizeof(str), format, ap);
> > >           va_end(ap);
> > >
> > > - if (!initialized) {
> > > + if (!gl_initialized) {
> > >                   SaVersionT logVersion = { 'A', 2, 1 };
> > >                   SaNameT stream_name = {.value =
> SA_LOG_STREAM_SYSTEM, .length =
> > sizeof(SA_LOG_STREAM_SYSTEM)};
> > > -         SaLogHandleT logHandle;
> > >
> > > -         error = saLogInitialize(&logHandle, NULL, &logVersion);
> > > +         error = saLogInitialize(&gl_logHandle, NULL, &logVersion);
> > >                   if (error != SA_AIS_OK) {
> > >                           syslog(LOG_INFO, "saLogInitialize FAILED: %u",
> error);
> > >                           goto done;
> > >                   }
> > >
> > > -         error = saLogStreamOpen_2(logHandle, &stream_name,
> NULL, 0,
> > SA_TIME_ONE_SECOND, &logStreamHandle);
> > > +         error = saLogStreamOpen_2(gl_logHandle, &stream_name,
> NULL, 0,
> > SA_TIME_ONE_SECOND, &gl_logStreamHandle);
> > >                   if (error != SA_AIS_OK) {
> > >                           syslog(LOG_INFO, "saLogStreamOpen_2 FAILED:
> %u", error);
> > > -                 if (saLogFinalize(logHandle) != SA_AIS_OK)
> > > +                 if (saLogFinalize(gl_logHandle) != SA_AIS_OK)
> > >                                   syslog(LOG_INFO, "saLogFinalize FAILED:
> %u", error);
> > >                           goto done;
> > >                   }
> > > -         initialized = 1;
> > > +         gl_initialized = 1;
> > >           }
> > >
> > >           logRecord.logTimeStamp = SA_TIME_UNKNOWN;
> > > @@ -65,7 +90,7 @@ void saflog(int priority, const SaNameT
> > >           logRecord.logBuffer = &logBuffer;
> > >           logBuffer.logBuf = (SaUint8T *)str;
> > >
> > > - error = saLogWriteLogAsync(logStreamHandle, 0, 0, &logRecord);
> > > + error = saLogWriteLogAsync(gl_logStreamHandle, 0, 0, &logRecord);
> > >
> > >   done:
> > >           /* fallback to syslog at ANY error, syslog prio same as saflog
> > severity */
> > >
> > >
------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to