isomorfeus-ferret 0.14.4 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +56 -6
- data/ext/isomorfeus_ferret_ext/extconf.rb +19 -1
- data/ext/isomorfeus_ferret_ext/frb_analysis.c +0 -4
- data/ext/isomorfeus_ferret_ext/frb_index.c +0 -4
- data/ext/isomorfeus_ferret_ext/frb_lazy_doc.c +4 -0
- data/ext/isomorfeus_ferret_ext/frb_qparser.c +1 -6
- data/ext/isomorfeus_ferret_ext/frb_search.c +0 -5
- data/ext/isomorfeus_ferret_ext/frb_store.c +66 -4
- data/ext/isomorfeus_ferret_ext/frb_utils.c +0 -4
- data/ext/isomorfeus_ferret_ext/frt_compound_io.c +4 -4
- data/ext/isomorfeus_ferret_ext/frt_except.c +11 -11
- data/ext/isomorfeus_ferret_ext/frt_fs_store.c +62 -88
- data/ext/isomorfeus_ferret_ext/frt_hash.c +32 -70
- data/ext/isomorfeus_ferret_ext/frt_ind.c +20 -20
- data/ext/isomorfeus_ferret_ext/frt_ind.h +1 -1
- data/ext/isomorfeus_ferret_ext/frt_index.c +78 -78
- data/ext/isomorfeus_ferret_ext/frt_index.h +11 -11
- data/ext/isomorfeus_ferret_ext/frt_mdbx_store.c +691 -0
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +4 -4
- data/ext/isomorfeus_ferret_ext/frt_ram_store.c +9 -9
- data/ext/isomorfeus_ferret_ext/frt_search.c +0 -3
- data/ext/isomorfeus_ferret_ext/frt_search.h +1 -1
- data/ext/isomorfeus_ferret_ext/frt_sort.c +2 -2
- data/ext/isomorfeus_ferret_ext/frt_store.c +6 -8
- data/ext/isomorfeus_ferret_ext/frt_store.h +43 -21
- data/ext/isomorfeus_ferret_ext/frt_threading.h +0 -16
- data/ext/isomorfeus_ferret_ext/isomorfeus_ferret.c +0 -9
- data/ext/isomorfeus_ferret_ext/mdbx.c +33632 -0
- data/ext/isomorfeus_ferret_ext/mdbx.h +5495 -0
- data/ext/isomorfeus_ferret_ext/test.c +20 -18
- data/ext/isomorfeus_ferret_ext/test_mdbx_store.c +19 -0
- data/ext/isomorfeus_ferret_ext/test_store.c +4 -8
- data/ext/isomorfeus_ferret_ext/test_threading.c +2 -2
- data/ext/isomorfeus_ferret_ext/tests_all.h +2 -0
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc82aa85a233a1eb67ae971fbd6e5704b1f6b14660ed5673f9292a3021f34837
|
4
|
+
data.tar.gz: dea91e29a2a3c14381067d05177c455d8953b74f0187e9b7610997c4a1bc68ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '064940571edfbb380795a71031274f6489010cdc28da4c26a64c769eee924593df069d72939a4f6e5e56b8b94398108e6e039c00526a250dbb5f51068a10880e'
|
7
|
+
data.tar.gz: 76edc3b5f07bd779498fe92d8630ec5f651e05eae82982fcedc853b9086fd7af84e827407ee0b2316456dc07bb7f508b63ded855278ff4ca38af18398ee7cc1e
|
data/LICENSE
CHANGED
@@ -28,14 +28,14 @@ Copyright (c) 2005-2006 David Balmain
|
|
28
28
|
MIT License as above
|
29
29
|
|
30
30
|
|
31
|
-
brotli_* files in ext/
|
31
|
+
brotli_* files in ext/isomorfeus_ferret_ext originally taken from https://github.com/google/brotli:
|
32
32
|
|
33
33
|
Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors.
|
34
34
|
|
35
35
|
MIT License as above
|
36
36
|
|
37
37
|
|
38
|
-
bzlib* files in ext/
|
38
|
+
bzlib* files in ext/isomorfeus_ferret_ext originally taken from git://sourceware.org/git/bzip2.git:
|
39
39
|
|
40
40
|
This program, "bzip2", the associated library "libbzip2", and all
|
41
41
|
documentation, are copyright (C) 1996-2019 Julian R Seward. All
|
@@ -76,7 +76,7 @@ Julian Seward, jseward@acm.org
|
|
76
76
|
bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
77
77
|
|
78
78
|
|
79
|
-
lz4* files in ext/
|
79
|
+
lz4* files in ext/isomorfeus_ferret_ext originally taken from https://github.com/lz4/lz4/tree/dev/lib:
|
80
80
|
|
81
81
|
Copyright (C) 2011-2020, Yann Collet.
|
82
82
|
|
@@ -107,7 +107,7 @@ You can contact the author at:
|
|
107
107
|
- LZ4 source repository : https://github.com/lz4/lz4
|
108
108
|
|
109
109
|
|
110
|
-
stem* and libstemmer* files in ext/
|
110
|
+
stem* and libstemmer* files in ext/isomorfeus_ferret_ext originally taken from https://snowballstem.org/:
|
111
111
|
|
112
112
|
Copyright (c) 2001, Dr Martin Porter
|
113
113
|
Copyright (c) 2004,2005, Richard Boulton
|
@@ -139,11 +139,62 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
139
139
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
140
140
|
|
141
141
|
|
142
|
+
mdbx* files in ext/isomorfeus_ferret_ext originally taken from https://gitflic.ru/project/erthink/libmdbx:
|
143
|
+
|
144
|
+
The OpenLDAP Public License
|
145
|
+
Version 2.8, 17 August 2003
|
146
|
+
|
147
|
+
Redistribution and use of this software and associated documentation
|
148
|
+
("Software"), with or without modification, are permitted provided
|
149
|
+
that the following conditions are met:
|
150
|
+
|
151
|
+
1. Redistributions in source form must retain copyright statements
|
152
|
+
and notices,
|
153
|
+
|
154
|
+
2. Redistributions in binary form must reproduce applicable copyright
|
155
|
+
statements and notices, this list of conditions, and the following
|
156
|
+
disclaimer in the documentation and/or other materials provided
|
157
|
+
with the distribution, and
|
158
|
+
|
159
|
+
3. Redistributions must contain a verbatim copy of this document.
|
160
|
+
|
161
|
+
The OpenLDAP Foundation may revise this license from time to time.
|
162
|
+
Each revision is distinguished by a version number. You may use
|
163
|
+
this Software under terms of this license revision or under the
|
164
|
+
terms of any subsequent revision of the license.
|
165
|
+
|
166
|
+
THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS
|
167
|
+
CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
168
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
169
|
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
170
|
+
SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE AUTHOR(S)
|
171
|
+
OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
172
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
173
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
174
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
175
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
176
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
177
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
178
|
+
POSSIBILITY OF SUCH DAMAGE.
|
179
|
+
|
180
|
+
The names of the authors and copyright holders must not be used in
|
181
|
+
advertising or otherwise to promote the sale, use or other dealing
|
182
|
+
in this Software without specific, written prior permission. Title
|
183
|
+
to copyright in this Software shall at all times remain with copyright
|
184
|
+
holders.
|
185
|
+
|
186
|
+
OpenLDAP is a registered trademark of the OpenLDAP Foundation.
|
187
|
+
|
188
|
+
Copyright 1999-2003 The OpenLDAP Foundation, Redwood City,
|
189
|
+
California, USA. All Rights Reserved. Permission to copy and
|
190
|
+
distribute verbatim copies of this document is granted.
|
191
|
+
|
192
|
+
|
142
193
|
The following licenses apply to files, which are distributed within the repo
|
143
194
|
but not distributed with the gem and not used at runtime:
|
144
195
|
|
145
196
|
|
146
|
-
For the
|
197
|
+
For the Reuters-21578 files in the misc/ferret_vs_others directory (reuters-corpus, etc.),
|
147
198
|
used for research for developing search engine technology:
|
148
199
|
|
149
200
|
The copyright for the text of newswire articles and Reuters
|
@@ -158,7 +209,6 @@ the data set (see "Availability & Questions").
|
|
158
209
|
|
159
210
|
Apache Lucene jars in the misc/ferret_vs_others directory:
|
160
211
|
|
161
|
-
|
162
212
|
Apache License
|
163
213
|
Version 2.0, January 2004
|
164
214
|
http://www.apache.org/licenses/
|
@@ -1,5 +1,23 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
-
|
3
|
+
WIN_PATTERNS = [
|
4
|
+
/bccwin/i,
|
5
|
+
/cygwin/i,
|
6
|
+
/djgpp/i,
|
7
|
+
/mingw/i,
|
8
|
+
/mswin/i,
|
9
|
+
/wince/i,
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
def win_platform?
|
13
|
+
ruby_platform = RbConfig::CONFIG['host_os']
|
14
|
+
!!WIN_PATTERNS.find {|r| ruby_platform =~ r }
|
15
|
+
end
|
16
|
+
|
17
|
+
$CFLAGS << ' -O2 -DMDBX_BUILD_FLAGS=\"-O2\" -Wall -Wno-sizeof-pointer-div'
|
18
|
+
|
19
|
+
if win_platform?
|
20
|
+
$LDFLAGS << ' -lntdll '
|
21
|
+
end
|
4
22
|
|
5
23
|
create_makefile('isomorfeus_ferret_ext')
|
@@ -2075,10 +2075,6 @@ static void Init_RegExpAnalyzer(void) {
|
|
2075
2075
|
rb_define_method(cRegExpAnalyzer, "token_stream", frb_re_analyzer_token_stream, 2);
|
2076
2076
|
}
|
2077
2077
|
|
2078
|
-
/* rdoc hack
|
2079
|
-
extern VALUE mFerret = rb_define_module("Ferret");
|
2080
|
-
*/
|
2081
|
-
|
2082
2078
|
/*
|
2083
2079
|
* Document-module: Ferret::Analysis
|
2084
2080
|
*
|
@@ -2811,10 +2811,6 @@ void Init_IndexReader(void) {
|
|
2811
2811
|
rb_define_method(cIndexReader, "to_enum", frb_ir_to_enum, 0);
|
2812
2812
|
}
|
2813
2813
|
|
2814
|
-
/* rdoc hack
|
2815
|
-
extern VALUE mFerret = rb_define_module("Ferret");
|
2816
|
-
*/
|
2817
|
-
|
2818
2814
|
/*
|
2819
2815
|
* Document-module: Ferret::Index
|
2820
2816
|
*
|
@@ -177,6 +177,7 @@ static VALUE frb_ld_lt(VALUE self, VALUE other) {
|
|
177
177
|
rLazyDoc *other_rld;
|
178
178
|
TypedData_Get_Struct(other, rLazyDoc, &frb_ld_t, other_rld);
|
179
179
|
other_h = frb_ld_to_h(other);
|
180
|
+
(void)other_rld;
|
180
181
|
}
|
181
182
|
VALUE self_h = frb_ld_to_h(self);
|
182
183
|
return rb_funcall(self_h, id_lt, 1, other_h);
|
@@ -190,6 +191,7 @@ static VALUE frb_ld_le(VALUE self, VALUE other) {
|
|
190
191
|
rLazyDoc *other_rld;
|
191
192
|
TypedData_Get_Struct(other, rLazyDoc, &frb_ld_t, other_rld);
|
192
193
|
other_h = frb_ld_to_h(other);
|
194
|
+
(void)other_rld;
|
193
195
|
}
|
194
196
|
VALUE self_h = frb_ld_to_h(self);
|
195
197
|
return rb_funcall(self_h, id_le, 1, other_h);
|
@@ -223,6 +225,7 @@ static VALUE frb_ld_gt(VALUE self, VALUE other) {
|
|
223
225
|
rLazyDoc *other_rld;
|
224
226
|
TypedData_Get_Struct(other, rLazyDoc, &frb_ld_t, other_rld);
|
225
227
|
other_h = frb_ld_to_h(other);
|
228
|
+
(void)other_rld;
|
226
229
|
}
|
227
230
|
VALUE self_h = frb_ld_to_h(self);
|
228
231
|
return rb_funcall(self_h, id_gt, 1, other_h);
|
@@ -236,6 +239,7 @@ static VALUE frb_ld_ge(VALUE self, VALUE other) {
|
|
236
239
|
rLazyDoc *other_rld;
|
237
240
|
TypedData_Get_Struct(other, rLazyDoc, &frb_ld_t, other_rld);
|
238
241
|
other_h = frb_ld_to_h(other);
|
242
|
+
(void)other_rld;
|
239
243
|
}
|
240
244
|
VALUE self_h = frb_ld_to_h(self);
|
241
245
|
return rb_funcall(self_h, id_ge, 1, other_h);
|
@@ -374,11 +374,6 @@ static VALUE frb_qp_set_tkz_fields(VALUE self, VALUE rfields) {
|
|
374
374
|
*
|
375
375
|
****************************************************************************/
|
376
376
|
|
377
|
-
/* rdoc hack
|
378
|
-
extern VALUE mFerret = rb_define_module("Ferret");
|
379
|
-
extern VALUE cQueryParser = rb_define_module_under(mFerret, "QueryParser");
|
380
|
-
*/
|
381
|
-
|
382
377
|
/*
|
383
378
|
* Document-class: Ferret::QueryParser::QueryParseException
|
384
379
|
*
|
@@ -410,7 +405,7 @@ void Init_QueryParseException(void) {
|
|
410
405
|
*
|
411
406
|
* If you want to use one of these characters in one of your terms you need
|
412
407
|
* to escape it with a \ character. \ escapes itself. The exception to this
|
413
|
-
* rule is within Phrases which
|
408
|
+
* rule is within Phrases which are strings surrounded by double quotes (and
|
414
409
|
* will be explained further bellow in the section on PhraseQueries). In
|
415
410
|
* Phrases, only ", | and <> have special meaning and need to be escaped if
|
416
411
|
* you want the literal value. <> is escaped \<\>.
|
@@ -4593,11 +4593,6 @@ static void Init_SpanNotQuery(void) {
|
|
4593
4593
|
rb_define_method(cSpanNotQuery, "initialize", frb_spanxq_init, 2);
|
4594
4594
|
}
|
4595
4595
|
|
4596
|
-
/* rdoc hack
|
4597
|
-
extern VALUE mFerret = rb_define_module("Ferret");
|
4598
|
-
extern VALUE mSearch = rb_define_module_under(mFerret, "Search");
|
4599
|
-
*/
|
4600
|
-
|
4601
4596
|
/*
|
4602
4597
|
* Document-module: Ferret::Search::Spans
|
4603
4598
|
*
|
@@ -10,6 +10,7 @@ VALUE cLockError;
|
|
10
10
|
VALUE cDirectory;
|
11
11
|
VALUE cRAMDirectory;
|
12
12
|
VALUE cFSDirectory;
|
13
|
+
VALUE cMDBXDirectory;
|
13
14
|
|
14
15
|
/****************************************************************************
|
15
16
|
* Lock Methods
|
@@ -418,6 +419,55 @@ static VALUE frb_fsdir_new(int argc, VALUE *argv, VALUE klass) {
|
|
418
419
|
return self;
|
419
420
|
}
|
420
421
|
|
422
|
+
|
423
|
+
/****************************************************************************
|
424
|
+
*
|
425
|
+
* MDBXDirectory Methods
|
426
|
+
*
|
427
|
+
****************************************************************************/
|
428
|
+
|
429
|
+
/*
|
430
|
+
* call-seq:
|
431
|
+
* MDBXDirectory.new(/path/to/env/, create = false)
|
432
|
+
*
|
433
|
+
* Create a new MDBXDirectory at +/path/to/env/+ which must be a valid path
|
434
|
+
* on your file system. If it doesn't exist it will be created. You can also
|
435
|
+
* specify the +create+ parameter. If +create+ is true the FSDirectory will
|
436
|
+
* be refreshed as new. That is to say, any existing files in the directory
|
437
|
+
* will be deleted. The default value for +create+ is false.
|
438
|
+
*
|
439
|
+
* path:: path to index directory. Must be a valid path on your system
|
440
|
+
* create:: set to true if you want any existing files in the directory to be
|
441
|
+
* deleted
|
442
|
+
*/
|
443
|
+
static VALUE frb_mdbxdir_new(int argc, VALUE *argv, VALUE klass) {
|
444
|
+
VALUE self, rpath, rcreate;
|
445
|
+
FrtStore *store;
|
446
|
+
bool create;
|
447
|
+
|
448
|
+
rb_scan_args(argc, argv, "11", &rpath, &rcreate);
|
449
|
+
StringValue(rpath);
|
450
|
+
create = RTEST(rcreate);
|
451
|
+
if (create) {
|
452
|
+
frb_create_dir(rpath);
|
453
|
+
}
|
454
|
+
if (!rb_funcall(rb_cFile, id_is_directory, 1, rpath)) {
|
455
|
+
rb_raise(cFileNotFoundError, "No directory <%s> found. Use :create => true to create one.", rs2s(rpath));
|
456
|
+
}
|
457
|
+
store = frt_open_mdbx_store(rs2s(rpath));
|
458
|
+
if (create) store->clear_all(store);
|
459
|
+
self = store->rstore;
|
460
|
+
if (self == Qnil || DATA_PTR(self) == NULL) {
|
461
|
+
self = TypedData_Wrap_Struct(klass, &frb_store_t, store);
|
462
|
+
store->rstore = self;
|
463
|
+
rb_ivar_set(self, id_ref_cnt, INT2FIX(0));
|
464
|
+
} else {
|
465
|
+
int ref_cnt = FIX2INT(rb_ivar_get(self, id_ref_cnt)) + 1;
|
466
|
+
rb_ivar_set(self, id_ref_cnt, INT2FIX(ref_cnt));
|
467
|
+
}
|
468
|
+
return self;
|
469
|
+
}
|
470
|
+
|
421
471
|
/****************************************************************************
|
422
472
|
*
|
423
473
|
* Init Function
|
@@ -504,7 +554,7 @@ void Init_RAMDirectory(void) {
|
|
504
554
|
}
|
505
555
|
|
506
556
|
/*
|
507
|
-
* Document-class: Ferret::Store::
|
557
|
+
* Document-class: Ferret::Store::FSDirectory
|
508
558
|
*
|
509
559
|
* File-system resident Directory implementation. The FSDirectory will use a
|
510
560
|
* single directory to store all of it's files. You should not otherwise
|
@@ -518,9 +568,20 @@ void Init_FSDirectory(void) {
|
|
518
568
|
rb_define_singleton_method(cFSDirectory, "new", frb_fsdir_new, -1);
|
519
569
|
}
|
520
570
|
|
521
|
-
/*
|
522
|
-
|
523
|
-
|
571
|
+
/*
|
572
|
+
* Document-class: Ferret::Store::MDBXDirectory
|
573
|
+
*
|
574
|
+
* MDBX resident Directory implementation. The MDBXDirectory will use a
|
575
|
+
* single MDBX database to store all of it's files. You should not otherwise
|
576
|
+
* touch this ddatabase. Modifying the database will corrupt the index.
|
577
|
+
* The one exception to this rule is you may need to delete stale
|
578
|
+
* lock files which have a ".lck" extension.
|
579
|
+
*/
|
580
|
+
void Init_MDBXDirectory(void) {
|
581
|
+
cMDBXDirectory = rb_define_class_under(mStore, "MDBXDirectory", cDirectory);
|
582
|
+
rb_define_alloc_func(cMDBXDirectory, frb_store_alloc);
|
583
|
+
rb_define_singleton_method(cMDBXDirectory, "new", frb_mdbxdir_new, -1);
|
584
|
+
}
|
524
585
|
|
525
586
|
/*
|
526
587
|
* Document-module: Ferret::Store
|
@@ -539,4 +600,5 @@ void Init_Store(void) {
|
|
539
600
|
Init_Lock();
|
540
601
|
Init_RAMDirectory();
|
541
602
|
Init_FSDirectory();
|
603
|
+
Init_MDBXDirectory();
|
542
604
|
}
|
@@ -1051,10 +1051,6 @@ static void Init_PriorityQueue(void) {
|
|
1051
1051
|
rb_define_method(cPriorityQueue, "adjust", frb_pq_adjust, 0);
|
1052
1052
|
}
|
1053
1053
|
|
1054
|
-
/* rdoc hack
|
1055
|
-
extern VALUE mFerret = rb_define_module("Ferret");
|
1056
|
-
*/
|
1057
|
-
|
1058
1054
|
/*
|
1059
1055
|
* Document-module: Ferret::Utils
|
1060
1056
|
*
|
@@ -142,21 +142,21 @@ static FrtInStream *cmpd_open_input(FrtStore *store, const char *file_name) {
|
|
142
142
|
FrtCompoundStore *cmpd = store->dir.cmpd;
|
143
143
|
FrtInStream *is;
|
144
144
|
|
145
|
-
|
145
|
+
pthread_mutex_lock(&store->mutex);
|
146
146
|
if (cmpd->stream == NULL) {
|
147
|
-
|
147
|
+
pthread_mutex_unlock(&store->mutex);
|
148
148
|
FRT_RAISE(FRT_IO_ERROR, "Can't open compound file input stream. Parent "
|
149
149
|
"stream is closed.");
|
150
150
|
}
|
151
151
|
|
152
152
|
entry = (FileEntry *)frt_h_get(cmpd->entries, file_name);
|
153
153
|
if (entry == NULL) {
|
154
|
-
|
154
|
+
pthread_mutex_unlock(&store->mutex);
|
155
155
|
FRT_RAISE(FRT_IO_ERROR, "File %s does not exist: ", file_name);
|
156
156
|
}
|
157
157
|
|
158
158
|
is = cmpd_create_input(cmpd->stream, entry->offset, entry->length);
|
159
|
-
|
159
|
+
pthread_mutex_unlock(&store->mutex);
|
160
160
|
|
161
161
|
return is;
|
162
162
|
}
|
@@ -29,19 +29,19 @@ char frt_xmsg_buffer[FRT_XMSG_BUFFER_SIZE];
|
|
29
29
|
char frt_xmsg_buffer_final[FRT_XMSG_BUFFER_FINAL_SIZE];
|
30
30
|
|
31
31
|
static frt_thread_key_t exception_stack_key;
|
32
|
-
static
|
32
|
+
static pthread_once_t exception_stack_key_once = PTHREAD_ONCE_INIT;
|
33
33
|
|
34
34
|
static void exception_stack_alloc(void) {
|
35
|
-
|
36
|
-
|
35
|
+
frb_thread_key_create(&exception_stack_key, NULL);
|
36
|
+
frb_thread_setspecific(exception_stack_key, NULL);
|
37
37
|
}
|
38
38
|
|
39
39
|
void frt_xpush_context(frt_xcontext_t *context) {
|
40
40
|
frt_xcontext_t *top_context;
|
41
|
-
|
42
|
-
top_context = (frt_xcontext_t *)
|
41
|
+
pthread_once(&exception_stack_key_once, *exception_stack_alloc);
|
42
|
+
top_context = (frt_xcontext_t *)frb_thread_getspecific(exception_stack_key);
|
43
43
|
context->next = top_context;
|
44
|
-
|
44
|
+
frb_thread_setspecific(exception_stack_key, context);
|
45
45
|
context->handled = true;
|
46
46
|
context->in_finally = false;
|
47
47
|
}
|
@@ -55,8 +55,8 @@ static void frt_xraise_context(frt_xcontext_t *context, volatile int excode, con
|
|
55
55
|
|
56
56
|
void frt_xraise(int excode, const char *const msg) {
|
57
57
|
frt_xcontext_t *top_context;
|
58
|
-
|
59
|
-
top_context = (frt_xcontext_t *)
|
58
|
+
pthread_once(&exception_stack_key_once, *exception_stack_alloc);
|
59
|
+
top_context = (frt_xcontext_t *)frb_thread_getspecific(exception_stack_key);
|
60
60
|
|
61
61
|
if (!top_context) {
|
62
62
|
FRT_XEXIT(ERROR_TYPES[excode], msg);
|
@@ -73,10 +73,10 @@ void frt_xraise(int excode, const char *const msg) {
|
|
73
73
|
|
74
74
|
void frt_xpop_context(void) {
|
75
75
|
frt_xcontext_t *top_cxt, *context;
|
76
|
-
|
77
|
-
top_cxt = (frt_xcontext_t *)
|
76
|
+
pthread_once(&exception_stack_key_once, *exception_stack_alloc);
|
77
|
+
top_cxt = (frt_xcontext_t *)frb_thread_getspecific(exception_stack_key);
|
78
78
|
context = top_cxt->next;
|
79
|
-
|
79
|
+
frb_thread_setspecific(exception_stack_key, context);
|
80
80
|
if (!top_cxt->handled) {
|
81
81
|
if (context) {
|
82
82
|
frt_xraise_context(context, top_cxt->excode, top_cxt->msg);
|