mojoSiteMapProvider is not thread safe

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
2/9/2007 11:00:02 AM
Gravatar
Total Posts 488

mojoSiteMapProvider is not thread safe

Sometimes I get an exception after recompile when trying to refresh 2 or more pages a time.
I found the issue, it's in mojoSiteMapProvider.cs:

public override SiteMapNode BuildSiteMap()
{
    if (rootNode != null)
    {
        return rootNode;
    }

    lock (objLock)
    {
       [init rootNode]
    }

    [...]
}

As checking for null is not under lock(), 2 threads check simultaneously and then try, one after another, to initialize it 2 times. The second attempt throws an exception.

P.S. And why do you create special object objLock instead of just lock(this)?
2/9/2007 2:24:05 PM
Gravatar
Total Posts 80

Re: mojoSiteMapProvider is not thread safe

I have also experienced the same problem on multiple occasions but could not figure out why...good catch.

-Jesse
2/9/2007 3:59:04 PM
Gravatar
Total Posts 18439

Re: mojoSiteMapProvider is not thread safe

Thanks Alexander, that is a good catch.

Interestingly, I based it on the sample XmlSiteMapProvider that I downloaded from MS quite a while back, and it has the same problem. ;-)

I've fixed it here and will check it in to svn a little later with some other changes.

Joe
You must sign in to post in the forums. This thread is closed to new posts.