Code Monkey home page Code Monkey logo

Comments (8)

cjheath avatar cjheath commented on July 30, 2024

GeoIP is not thread-safe, because it seeks a file pointer and reads from that location multiple times for each lookup. If you are initialising it once, you should store the handle in thread-local storage.

from geoip.

kenn avatar kenn commented on July 30, 2024

I'm not using threads, just a regular Rails app on Unicorn, which is single threaded. Do I still need to assign it to thread-local?

from geoip.

cjheath avatar cjheath commented on July 30, 2024

Try it with a Mutex and see if you still get problems, but the behaviour you describe sounds very like a race.

from geoip.

kenn avatar kenn commented on July 30, 2024

Well, we don't have config.threadsafe! on production, which means all requests are inside Rack::Lock so it's already mutex'd.

from geoip.

cjheath avatar cjheath commented on July 30, 2024

Perhaps, but try it anyway. EventMachine can still flip things around, I believe.

from geoip.

kenn avatar kenn commented on July 30, 2024

Will try, but I doubt that's the direct cause. We're not using EventMachine either. (If you use EM you'd use Rainbows! instead of Unicorn) It's a vanilla Rails 3.2 app with Unicorn, which I believe is the most popular setup.

from geoip.

cjheath avatar cjheath commented on July 30, 2024

Ok, well then I have no idea... but a lot of folk are using GeoIP without problems, including long-running instances. If you can find a cause and/or a fix, I'll be happy to re-open this issue.

from geoip.

kenn avatar kenn commented on July 30, 2024

Yeah I had been using the gem for quite a while without problems, then the problem started to appear at some point. I'll update when I find something out. Thanks for your time!

from geoip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.