Results 1 to 5 of 5

Thread: onAppStop called from another thread?

  1. #1
    Join Date
    Jul 2011
    Posts
    104

    Default onAppStop called from another thread?

    Hey guys!

    Hope all is well with the Wowza team.

    Seeing something super bizarre when onAppStop gets called, I'm hoping to get your take on it, so here goes...

    Inside onAppStop we're doing some cleanup and sending some variables (like the max unique user count) to the DB. This variable, maxUniqueAttendees is private as is instantiated inside onAppStart and incremented after some checks we make against the SO when it syncs. We've checked and double-checked that the value is the correct amount when testing locally and our staging environments, but in production the value is *sometimes* something way off, and I'm thinking it's a value from another thread perhaps.

    Is that even possible across app instances?

    Please let me know if I didn't explain it clearly, or if I would need to provide some simplified source. Thanks so much guys, you're the best!

  2. #2

    Default

    Hi,

    If you have made the variable a static variable then it is certainly possible. Otherwise, onAppStop would not be called from another appInstance.

    Perhaps a code sample would be good.

    Roger.

  3. #3
    Join Date
    Jul 2011
    Posts
    104

    Default

    Hey Roger!

    yeah, the variable is private but not static in this case. Below is a SUPER slimmed down version of my module, however it represents the essence of the issue:

    package com.removed.module;

    public class deleteme extends ModuleBase
    {
    static public final String SESSION_SONAME = "spinsession";

    private int _maxAttendees = 0;

    public void onAppStart(IApplicationInstance appInstance)
    {
    this.initSO(appInstance, SESSION_SONAME);
    }

    public void onAppStop(IApplicationInstance appInstance)
    {
    ISharedObjects sharedObjects = appInstance.getSharedObjects();
    ISharedObject sessionSO = sharedObjects.get(SESSION_SONAME);

    if (sessionSO != null)
    {
    sessionSO.lock();

    try
    {
    sessionSO.release();
    }
    catch(Exception e)
    {
    //
    }
    finally
    {
    sessionSO.unlock();
    }
    }

    /**
    * PERSIST _maxAttendees to the DB...
    * This is where it gets weird, because it seems like the number is correct,
    * then if I check the DB a few minutes later for the same record, the value
    * is LOWER than it was previously.
    *
    * Sometimes the drop in value happens once, sometimes 2 or 3 times, super weird
    */
    RoomService.setMaxAttendeesAndHypes(_maxAttendees);
    }

    public void onConnect(IClient client, RequestFunction function, AMFDataList params)
    {
    ISharedObjects sharedObjects = client.getAppInstance().getSharedObjects();
    ISharedObject sessionSO = sharedObjects.get(SESSION_SONAME);

    // Synchronize the SO and add the slot here... (removed for brevity)

    // CALCULATE the new value for _maxAttendees
    int size = sessionSO.size();
    if (size > _maxAttendees)
    _maxAttendees = size;

    // The value of _maxAttendees is correct at this point, always
    }

    private void initSO(IApplicationInstance appInstance, String soName)
    {
    ISharedObjects sharedObjects = appInstance.getSharedObjects();
    ISharedObject so = new SharedObject(soName);
    sharedObjects.put(soName, so);

    so.lock();

    try
    {
    so.acquire();
    }
    catch (Exception e)
    {
    //
    }
    finally
    {
    so.unlock();
    }
    }
    }

  4. #4

    Default

    Hi,

    RoomService.setMaxAttendeesAndHypes(_maxAttendees) ; looks looks a static method so if you have multiple applications using the same module and calling the same method then there doesn't appear to be any way that it co differentiate between which one called it.

    Also be careful about separate appInstances. It is very easy to misconfigure a player and accidentally start a separate appInstance from the default one.

    Do you need something like RoomService.setMaxAttendeesAndHypes(appInstance, _maxAttendees); maybe?

    Roger.

    BTW, if you use code tags in your replies instead of quote tags then the formatting will be retained. Use the Go Advanced button bottom right of the reply box.

  5. #5
    Join Date
    Jul 2011
    Posts
    104

    Default

    Quote Originally Posted by roger_l View Post
    RoomService.setMaxAttendeesAndHypes(_maxAttendees) ; looks looks a static method so if you have multiple applications using the same module and calling the same method then there doesn't appear to be any way that it co differentiate between which one called it.
    DUDE. What was I thinking!!??!

    Thanks so much for spotting that man, I totally forgot about those being static. Always good to have another set of eyes on the problem. Thanks so much dude, I'll fix and give it another go.

    Cheers!

Similar Threads

  1. sendClientOnStatusError from Thread
    By KoWa90 in forum Wowza Streaming Server Java API
    Replies: 1
    Last Post: 03-14-2014, 07:54 AM
  2. Replies: 1
    Last Post: 12-04-2013, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •