From f65ae434e4d244235283c281d42f477247a980d4 Mon Sep 17 00:00:00 2001 From: Patrick Mahoney Date: Sat, 17 Dec 2011 07:53:15 -0600 Subject: [PATCH] Clear the error pointer so that it may be reused. --- lib/process_shared/psem.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/process_shared/psem.rb b/lib/process_shared/psem.rb index b425db2..bc42e19 100644 --- a/lib/process_shared/psem.rb +++ b/lib/process_shared/psem.rb @@ -23,6 +23,9 @@ module ProcessShared # Replace methods in `syms` with error checking wrappers that # invoke the original psem method and raise an appropriate # error. + # + # The last argument is assumed to be a pointer to a pointer + # where either a psem error or NULL will be stored. def psem_error_check(*syms) syms.each do |sym| method = self.method(sym) @@ -32,7 +35,8 @@ module ProcessShared errp = args[-1] unless errp.nil? begin - err = Error.new(errp.get_pointer(0)) + err = Error.new(errp.read_pointer) + errp.write_pointer(nil) if err[:source] == PSem.e_source_system raise SystemCallError.new("error in #{sym}", err[:errno]) else