| 1 | #!/usr/bin/perl | ||
| 2 | # | ||
| 3 | # copyright (c) 2005, Eric Rollins, all rights reserved, worldwide | ||
| 4 | # | ||
| 5 | # | ||
| 6 | # | ||
| 7 | |||
| 8 | use strict; | ||
| 9 | use warnings; | ||
| 10 | |||
| 11 | package Genezzo::Contrib::Clustered::GLock::GLockDLM; | ||
| 12 | |||
| 13 | # Locking for Genezzo using OpenDLM | ||
| 14 | use Inline (C => 'DATA', | ||
| 15 | DIRECTORY => '/Inline', # Apache needs a writeable directory | ||
| 16 | LIBS => '-ldlm'); | ||
| 17 | |||
| 18 | require Exporter; | ||
| 19 | |||
| 20 | Inline->init; # help for "require GLockDLM" | ||
| 21 | |||
| 22 | our @ISA = qw(Exporter); | ||
| 23 | our @EXPORT = qw(dlm_lock dlm_unlock dlm_promote); | ||
| 24 | |||
| 25 | sub dlm_lock() | ||
| 26 | { | ||
| 27 | my ($name, $shared, $blocking) = @_; | ||
| 28 | |||
| 29 | my $ret = return dlm_lock_impl($name, $shared, $blocking); | ||
| 30 | |||
| 31 | if($ret == -1){ | ||
| 32 | die "DEADLOCK"; | ||
| 33 | } | ||
| 34 | |||
| 35 | return $ret; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub dlm_unlock() | ||
| 39 | { | ||
| 40 | my ($lockid) = @_; | ||
| 41 | |||
| 42 | return dlm_unlock_impl($lockid); | ||
| 43 | } | ||
| 44 | |||
| 45 | sub dlm_promote() | ||
| 46 | { | ||
| 47 | my ($name, $lockid, $blocking) = @_; | ||
| 48 | |||
| 49 | my $ret = dlm_promote_impl($name, $lockid, $blocking); | ||
| 50 | |||
| 51 | if($ret == -1){ | ||
| 52 | die "DEADLOCK"; | ||
| 53 | } | ||
| 54 | |||
| 55 | return $ret; | ||
| 56 | } | ||
| 57 | |||
| 58 | sub dlm_demote() | ||
| 59 | { | ||
| 60 | my ($name, $lockid, $blocking) = @_; | ||
| 61 | |||
| 62 | my $ret = dlm_demote_impl($name, $lockid, $blocking); | ||
| 63 | |||
| 64 | if($ret == -1){ | ||
| 65 | die "DEADLOCK"; | ||
| 66 | } | ||
| 67 | |||
| 68 | return $ret; | ||
| 69 | } | ||
| 70 | |||
| 71 | sub dlm_ast_poll() | ||
| 72 | { | ||
| 73 | return dlm_ast_poll_impl(); | ||
| 74 | } | ||
| 75 | |||
| 76 | sub dlm_set_notify() | ||
| 77 | { | ||
| 78 | return dlm_set_notify_impl(); | ||
| 79 | } | ||
| 80 | |||
| 81 | BEGIN | ||
| 82 | { | ||
| 83 | print STDERR "Genezzo::Contrib::Clustered::GLock::GLockDLM installed\n"; | ||
| 84 | } | ||
| 85 | |||
| 86 | 1; | ||
| 87 | |||
| 88 | __DATA__ |