Skip to content

Fix race-condition during vips load #114

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

Merged
merged 1 commit into from
Jul 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 13 additions & 32 deletions lib/vips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ module Vips
# about as crude as you could get
$vips_debug = false

# allow to skip GI autoload
$vips_skip_autoload ||= false

# Turn debug logging on and off.
#
# @param dbg [Boolean] Set true to print debug log messages
Expand All @@ -41,38 +44,8 @@ def self.set_debug dbg

class << self
# @private
def const_missing(name)
log "Vips::const_missing: #{name}"

init()
if const_defined?(name)
const_get(name)
else
super
end
end

# @private
def method_missing(name, *args, &block)
log "Vips::method_missing: #{name}, #{args}, #{block}"

init()
if respond_to?(name)
__send__(name, *args, &block)
else
super
end
end

# @private
def init(*argv)
log "Vips::init: #{argv}"

class << self
remove_method(:init)
remove_method(:const_missing)
remove_method(:method_missing)
end
def load_gi_module(*argv)
log "Vips::load_gi_module: #{argv}"

loader = Loader.new(self, argv)
begin
Expand All @@ -92,6 +65,11 @@ class << self
require 'vips/call'
require 'vips/image'
require 'vips/version'

# Make sure we only get called once.
def self.load_gi_module; false; end

true
end
end

Expand Down Expand Up @@ -146,6 +124,9 @@ def post_load(repository, namespace)
# this makes vips keep a list of all active objects which we can print out
Vips::leak_set true if $vips_debug

# Initialize GI
Vips::load_gi_module unless $vips_skip_autoload

# @private
def showall
if $vips_debug
Expand Down