[reSIProcate] [spam] Re: [spam] Re: static StatisticsMessage::AtomicPayload appStats; in poll() may not thread safe
Jason Fischl
jason at counterpath.com
Tue Oct 24 11:42:20 CDT 2006
It is fixed on main.
On 10/24/06, maodonghu <hhmmdd at tom.com> wrote:
>
> Hi, resip
>
> anyone can fix this bug?
>
> ======== 2006-10-19 01:11:28 ========
>
>
>
> hi maodonghu,
>
> well, i'm sorry , i doesn't careful inspection with your question,
>
> that is a bug with the code, em. may be appStats can move into static global area. I think that appStats can initialize first. may be to avert the thread safe issue.
>
> btw, why you use multi-stack in your process ?
>
> sincerely,
> jinti
>
>
> 在06-10-18, maodonghu <hhmmdd at tom.com> 写道:
> >
> > Hi, shen jinti
> >
> > By the way, I use Pentinum D, it has 2 CPU, so the exception may be easy to encounter.
> >
> >
> > ======== 2006-10-18 10:37:34 ========
> >
> >
> >
> > hi maodonghu,
> >
> > you must compile with /MD or /MT option in you all project.
> >
> > jinti
> >
> >
> >
> > 在06-10-18,maodonghu < hhmmdd at tom.com> 写道:
> >
> > > hi,
> > >
> > > I found my multi-thread program that using resiprocate will crashed sometimes when startup, the place is
> > >
> > > void
> > > StatisticsMessage::AtomicPayload::loadIn(const Payload& payload)
> > > {
> > > Lock lock(mMutex); // --> here cause crash, because the mMutex may have not finished its constructor yet.
> > > Payload::operator=(payload);
> > > }
> > >
> > > then I research the source code, I found
> > >
> > > void
> > > StatisticsManager::poll()
> > > {
> > > // get snapshot data now..
> > > tuFifoSize = mStack.mTransactionController.getTuFifoSize();
> > > transportFifoSizeSum = mStack.mTransactionController.sumTransportFifoSizes();
> > > transactionFifoSize = mStack.mTransactionController.getTransactionFifoSize();
> > > activeTimers = mStack.mTransactionController.getTimerQueueSize();
> > > activeClientTransactions = mStack.mTransactionController.getNumClientTransactions();
> > > activeServerTransactions = mStack.mTransactionController.getNumServerTransactions();
> > >
> > > static StatisticsMessage::AtomicPayload appStats; // --> here may not thread safe
> > > appStats.loadIn(*this);
> > >
> > > // let the app do what it wants with it
> > > mStack.post(StatisticsMessage(appStats));
> > > }
> > >
> > >
> > > Because I have multi-SipStacks in my program, so I have multi-StackThread, I think the usage of static local variable here may not thread safe, appStats should be a static member of class StatisticsManager.
> > >
> > > the MSDN help also tell us:
> > >
> > > Note
> > > Assigning to a static local variable is not thread safe and is not recommended as a programming practice.
> > >
> > >
> > >
> > > maodonghu
> > > hhmmdd at tom.com
> > > 2006-10-18
> > >
> > > _______________________________________________
> > > resiprocate-devel mailing list
> > > resiprocate-devel at list.sipfoundry.org
> > > https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel
> >
> >
> >
> >
> > = = = = = = = = = = = = = = = = = = = = = =
> >
> > maodonghu
> > hhmmdd at tom.com
> > 2006-10-18
> >
>
>
>
>
> = = = = = = = = = = = = = = = = = = = = = =
>
> maodonghu
> hhmmdd at tom.com
> 2006-10-24
>
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel at list.sipfoundry.org
> https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel
>
>
More information about the resiprocate-devel
mailing list