Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pling thread safe by using a connection pool and thread local storage #2

Merged
merged 4 commits into from Jul 2, 2014

Commits on Jun 24, 2014

  1. Use a pool for APN connections

    The connections to APN are the only connections in pling that are
    steadily held open (Apple requires this).
    
    Without a connection pool there might be race-conditions when using
    pling in a multi-threaded context.
    
    This adds a connection pool so that only one thread at a time can use an
    open connection to APN.
    mrnugget committed Jun 24, 2014
    Configuration menu
    Copy the full SHA
    40c059f View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2014

  1. Cache connections in GCM and C2DM gateways per thread

    Instead of caching the connections in the C2DM and GCM gateways in
    instance variables, we use the thread local storage provided by
    `Thread.current`.
    
    The reason for that is thread safety, since gateway objects are
    practically singleton objects that can be used by multiple threads at
    the same time.
    
    With this change each thread that calls `deliver` on a gateway gets a
    fresh connection object and doesn't interfer with the other threads'
    state.
    mrnugget committed Jun 27, 2014
    Configuration menu
    Copy the full SHA
    982f27b View commit details
    Browse the repository at this point in the history

Commits on Jun 28, 2014

  1. Do not cache C2DM/GCM gateway connections

    Using Thread.current is basically using a hidden global variable. This
    is simpler and safer.
    mrnugget committed Jun 28, 2014
    Configuration menu
    Copy the full SHA
    14b167f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    aad18bc View commit details
    Browse the repository at this point in the history