Last change
on this file was
12888,
checked in by westram, 10 years ago
|
- fix #603
- abort all TAs and close all DBs
- in arb-perl death-handler
- on exit (i.e. perl scripts will now abort unclosed TAs - not sure whether they did commit b4)
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
1.7 KB
|
Line | |
---|
1 | package ARB; |
---|
2 | |
---|
3 | use strict; |
---|
4 | use vars qw($VERSION @ISA @EXPORT); |
---|
5 | |
---|
6 | require Exporter; |
---|
7 | require DynaLoader; |
---|
8 | |
---|
9 | @ISA = qw(Exporter DynaLoader); |
---|
10 | # Items to export into callers namespace by default. Note: do not export |
---|
11 | # names by default without a very good reason. Use EXPORT_OK instead. |
---|
12 | # Do not simply export all your public functions/methods/constants. |
---|
13 | @EXPORT = qw( |
---|
14 | |
---|
15 | ); |
---|
16 | $VERSION = '0.01'; |
---|
17 | |
---|
18 | bootstrap ARB $VERSION; |
---|
19 | |
---|
20 | # globally catch die, redirect to arb_message, then confess |
---|
21 | package CORE::GLOBAL; |
---|
22 | use subs 'die'; |
---|
23 | my $already_dying = 0; |
---|
24 | |
---|
25 | sub show_arb_message($) { |
---|
26 | my ($msg) = @_; |
---|
27 | $msg =~ s/\n/\\n/g; |
---|
28 | $msg =~ s/'/"/g; |
---|
29 | system("arb_message '$msg'"); |
---|
30 | } |
---|
31 | |
---|
32 | sub die { |
---|
33 | if ($already_dying==0) { |
---|
34 | $already_dying++; # do not recurse |
---|
35 | |
---|
36 | ARB::prepare_to_die(); # abort all transactions and close all databases (too avoid deadlock; see #603) |
---|
37 | |
---|
38 | my ($msg) = @_; |
---|
39 | $msg =~ s/\n+$//g; # remove trailing LFs |
---|
40 | if ($msg eq '') { $msg = 'Unknown macro execution error'; } |
---|
41 | else { $msg = "Macro execution error: '$msg'"; } |
---|
42 | show_arb_message($msg."\n(see console for details)"); |
---|
43 | |
---|
44 | use Carp; |
---|
45 | Carp::confess("Macro execution error: '$msg'"); # recurses into this sub |
---|
46 | } |
---|
47 | else { |
---|
48 | CORE::die @_; |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | # Preloaded methods go here. |
---|
53 | |
---|
54 | # Autoload methods go after =cut, and are processed by the autosplit program. |
---|
55 | |
---|
56 | 1; |
---|
57 | __END__ |
---|
58 | # Below is the stub of documentation for your module. You better edit it! |
---|
59 | |
---|
60 | =head1 NAME |
---|
61 | |
---|
62 | ARB - Perl extension for ARB |
---|
63 | |
---|
64 | =head1 SYNOPSIS |
---|
65 | |
---|
66 | use ARB; |
---|
67 | |
---|
68 | =head1 DESCRIPTION |
---|
69 | |
---|
70 | The ARB perl module provides access to a ARB databases. You may |
---|
71 | connect to a remote database (e.g. a running instance of ARB_NTREE) or |
---|
72 | open your own database. |
---|
73 | |
---|
74 | =head1 AUTHOR |
---|
75 | |
---|
76 | ARB development, devel@arb-home.de |
---|
77 | |
---|
78 | =head1 SEE ALSO |
---|
79 | |
---|
80 | perl(1). |
---|
81 | |
---|
82 | =cut |
---|
Note: See
TracBrowser
for help on using the repository browser.