[PATCH 5/5] Set stale on prerecap cache


Ian Bell <IBell@...>
 

From c7edaee5bcae63bbcbe0efa3e6e119bf0d27fb87 Mon Sep 17 00:00:00 2001

Message-Id: <c7edaee5bcae63bbcbe0efa3e6e119bf0d27fb87.1351009358.git.ibell@...>

In-Reply-To: <39c85ec4d82fe063d0ea61ff7bd3863ae57cd12a.1351009358.git.ibell@...>

References: <39c85ec4d82fe063d0ea61ff7bd3863ae57cd12a.1351009358.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Tue, 23 Oct 2012 14:08:15 +0100

Subject: [PATCH 5/5] Set stale on prerecap cache

 

Mdified messages replaying from prerecap cache to be stale.

 

Signed-off-by: Ian Bell <ibell@...>

---

mama/c_cpp/src/c/dqstrategy.c          |    6 ++++++

mama/c_cpp/src/c/dqstrategy.h          |    1 +

mama/c_cpp/src/c/listenermsgcallback.c |    8 +++++++-

3 files changed, 14 insertions(+), 1 deletion(-)

 

diff --git a/mama/c_cpp/src/c/dqstrategy.c b/mama/c_cpp/src/c/dqstrategy.c

index bd31c78..a29873a 100644

--- a/mama/c_cpp/src/c/dqstrategy.c

+++ b/mama/c_cpp/src/c/dqstrategy.c

@@ -559,6 +559,7 @@ dqContext_initializeContext (mamaDqContext *ctx, int cacheSize,

     ctx->mSenderId      = 0;

     ctx->mSenderId      = 0;

     ctx->mRecapRequest  = recap;

+    ctx->mSetCacheMsgStale = 0;

     if (cacheSize > 0)

     {

         /*We may be simply resetting the context*/

@@ -688,6 +689,10 @@ dqContext_fillGap (mamaDqContext *ctx, mama_seqnum_t end, mamaSubscription subsc

             {

                 mama_log (MAMA_LOG_LEVEL_FINE,

                                "Found a message for gap.");

+                if (ctx->mSetCacheMsgStale)

+                {

+                    msgUtils_setStatus (ctx->mCache[cur], MAMA_MSG_STATUS_STALE);

+                }

                 mamaSubscription_forwardMsg(subscription, ctx->mCache[cur]);

                 if (++nextSeqNum == end)

@@ -706,6 +711,7 @@ dqContext_fillGap (mamaDqContext *ctx, mama_seqnum_t end, mamaSubscription subsc

         } while (cur != ctx->mCurCacheIdx);

     }

+    ctx->mSetCacheMsgStale = 0;

     return 0;

}

diff --git a/mama/c_cpp/src/c/dqstrategy.h b/mama/c_cpp/src/c/dqstrategy.h

index 0842784..e4cc7c9 100644

--- a/mama/c_cpp/src/c/dqstrategy.h

+++ b/mama/c_cpp/src/c/dqstrategy.h

@@ -67,6 +67,7 @@ typedef struct

     mama_u64_t    mSenderId;

     uint8_t       mDoNotForward;

+    mama_bool_t   mSetCacheMsgStale;

} mamaDqContext;

 typedef struct dqStrategy_* dqStrategy;

diff --git a/mama/c_cpp/src/c/listenermsgcallback.c b/mama/c_cpp/src/c/listenermsgcallback.c

index 81ff1fa..9b00b78 100644

--- a/mama/c_cpp/src/c/listenermsgcallback.c

+++ b/mama/c_cpp/src/c/listenermsgcallback.c

@@ -460,6 +460,12 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

         && msgType != MAMA_MSG_TYPE_EXPIRE

         && msgType != MAMA_MSG_TYPE_UNKNOWN))

     {

+        /* If we are waiting for a recap and using the pre-recap cache, we

+           want to pass on any cached updates as STALE when the recap arrives */

+        if (state == DQ_STATE_WAITING_FOR_RECAP && mamaTransportImpl_preRecapCacheEnabled (transport))

+        {

+            ctx->mDqContext.mSetCacheMsgStale = 1;

+        }

         /*Add this message to the cache. If the message after the initial

          * results in a gap we will attempt to fill the gap from this cache

          * before asking for a recap.*/

@@ -475,7 +481,7 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

             mama_log (MAMA_LOG_LEVEL_FINE,

                            "%s%s %s%s"

                            " Subscription ignoring message received prior"

-                           " to initial or recap. Type: %d %d %p",

+                           " to initial or recap. Type: %d %s %p",

                            userSymbolFormatted, ctxSymbolFormatted,

                            msgType, mamaMsg_toString(msg), ctx);

         }

--

1.7.9.5

 




Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.