prometheus-client-mmap 0.7.0.beta45.9 → 0.7.0.beta45.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/fast_mmaped_file/mmap.c +2 -2
- data/ext/fast_mmaped_file/mmap.h +8 -7
- data/ext/fast_mmaped_file/value_access.c +22 -20
- data/lib/fast_mmaped_file.bundle +0 -0
- data/lib/prometheus/client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5be03b2cf017dc8f05006a950baed4584f438ea2
|
4
|
+
data.tar.gz: 8710f5d2514afc53a5bf38f0d5169c1b20f9b1cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43aff1c44ec220cec46f22fee1c0566dcfd9e147edeb6eae86b0671f26e7f0bb2fb4da003545df6a15d9a0361d7298168e1080f4169dc6ecbba39aa14cd49b3a
|
7
|
+
data.tar.gz: 43d52f9e8614382c930b856c538f4dfbd7e95b7753ecd9c5dd368cdb8512b60fd9e364994bdfbc8f7f404a73d377e2795f6f089c6ff6433584ab108402aef96f
|
data/ext/fast_mmaped_file/mmap.c
CHANGED
@@ -226,12 +226,12 @@ VALUE mm_init(VALUE obj, VALUE fname) {
|
|
226
226
|
}
|
227
227
|
|
228
228
|
addr = mmap(0, size, pmode, vscope, fd, offset);
|
229
|
-
close(fd);
|
230
229
|
|
231
230
|
if (addr == MAP_FAILED || !addr) {
|
231
|
+
close(fd);
|
232
232
|
rb_raise(rb_eArgError, "mmap failed (%d)", errno);
|
233
233
|
}
|
234
|
-
|
234
|
+
i_mm->t->fd = fd;
|
235
235
|
i_mm->t->addr = addr;
|
236
236
|
i_mm->t->len = size;
|
237
237
|
if (!init) {
|
data/ext/fast_mmaped_file/mmap.h
CHANGED
@@ -28,6 +28,7 @@ typedef struct {
|
|
28
28
|
int semid, shmid;
|
29
29
|
size_t len, real;
|
30
30
|
off_t offset;
|
31
|
+
int fd;
|
31
32
|
char *path, *template;
|
32
33
|
} mm_mmap;
|
33
34
|
|
@@ -36,13 +37,13 @@ typedef struct {
|
|
36
37
|
mm_mmap *t;
|
37
38
|
} mm_ipc;
|
38
39
|
|
39
|
-
#define GET_MMAP(obj, i_mm, t_modify)
|
40
|
-
Data_Get_Struct(obj, mm_ipc, i_mm);
|
41
|
-
if (!i_mm->t->path || i_mm->t->
|
42
|
-
rb_raise(rb_eIOError, "unmapped file");
|
43
|
-
}
|
44
|
-
if ((t_modify & MM_MODIFY) && (i_mm->t->flag & MM_FROZEN)) {
|
45
|
-
rb_error_frozen("mmap");
|
40
|
+
#define GET_MMAP(obj, i_mm, t_modify) \
|
41
|
+
Data_Get_Struct(obj, mm_ipc, i_mm); \
|
42
|
+
if (!i_mm->t->path || i_mm->t->fd == 0 || i_mm->t->addr == NULL || i_mm->t->addr == MAP_FAILED) { \
|
43
|
+
rb_raise(rb_eIOError, "unmapped file"); \
|
44
|
+
} \
|
45
|
+
if ((t_modify & MM_MODIFY) && (i_mm->t->flag & MM_FROZEN)) { \
|
46
|
+
rb_error_frozen("mmap"); \
|
46
47
|
}
|
47
48
|
|
48
49
|
VALUE mm_s_alloc(VALUE obj);
|
@@ -12,24 +12,32 @@
|
|
12
12
|
|
13
13
|
#include "utils.h"
|
14
14
|
|
15
|
-
static int
|
16
|
-
int fd;
|
15
|
+
static int close_file(mm_ipc *i_mm) {
|
16
|
+
int rv = close(i_mm->t->fd);
|
17
|
+
i_mm->t->fd = 0;
|
18
|
+
return rv;
|
19
|
+
}
|
20
|
+
|
21
|
+
static int open_and_extend_file(mm_ipc *i_mm, size_t len) {
|
22
|
+
if (i_mm->t->fd == 0) {
|
23
|
+
int fd = i_mm->t->fd;
|
17
24
|
|
18
|
-
|
19
|
-
|
25
|
+
if ((fd = open(i_mm->t->path, i_mm->t->smode)) == -1) {
|
26
|
+
return with_exception(rb_eArgError, "%s: Can't open %s", __FILE__, i_mm->t->path);
|
27
|
+
}
|
28
|
+
i_mm->t->fd = fd;
|
20
29
|
}
|
21
30
|
|
22
|
-
if (lseek(fd, len - i_mm->t->len - 1, SEEK_END) == -1) {
|
23
|
-
|
31
|
+
if (lseek(i_mm->t->fd, len - i_mm->t->len - 1, SEEK_END) == -1) {
|
32
|
+
close_file(i_mm);
|
24
33
|
return with_exception(rb_eIOError, "Can't lseek %zu", len - i_mm->t->len - 1);
|
25
34
|
}
|
26
35
|
|
27
|
-
if (write(fd, "\000", 1) != 1) {
|
28
|
-
|
36
|
+
if (write(i_mm->t->fd, "\000", 1) != 1) {
|
37
|
+
close_file(i_mm);
|
29
38
|
return with_exception(rb_eIOError, "Can't extend %s", i_mm->t->path);
|
30
39
|
}
|
31
40
|
|
32
|
-
*fd_p = fd;
|
33
41
|
return SUCCESS;
|
34
42
|
}
|
35
43
|
|
@@ -46,8 +54,8 @@ static int perform_munmap(mm_ipc *i_mm) {
|
|
46
54
|
return SUCCESS;
|
47
55
|
}
|
48
56
|
|
49
|
-
static int perform_mmap(mm_ipc *i_mm,
|
50
|
-
MMAP_RETTYPE addr = mmap(0, len, i_mm->t->pmode, i_mm->t->vscope, fd, i_mm->t->offset);
|
57
|
+
static int perform_mmap(mm_ipc *i_mm, size_t len) {
|
58
|
+
MMAP_RETTYPE addr = mmap(0, len, i_mm->t->pmode, i_mm->t->vscope, i_mm->t->fd, i_mm->t->offset);
|
51
59
|
|
52
60
|
if (addr == MAP_FAILED) {
|
53
61
|
return with_exception(rb_eArgError, "mmap failed");
|
@@ -69,21 +77,15 @@ static int expand(mm_ipc *i_mm, size_t len) {
|
|
69
77
|
return FAILURE;
|
70
78
|
}
|
71
79
|
|
72
|
-
|
73
|
-
|
74
|
-
if (!open_and_extend_file(i_mm, len, &fd)) {
|
80
|
+
if (!open_and_extend_file(i_mm, len)) {
|
75
81
|
return FAILURE;
|
76
82
|
}
|
77
83
|
|
78
|
-
if (!perform_mmap(i_mm,
|
79
|
-
|
84
|
+
if (!perform_mmap(i_mm, len)) {
|
85
|
+
close_file(i_mm);
|
80
86
|
return FAILURE;
|
81
87
|
}
|
82
88
|
|
83
|
-
if (close(fd) == -1) {
|
84
|
-
return with_exception(rb_eArgError, "Can't close %s", i_mm->t->path);
|
85
|
-
}
|
86
|
-
|
87
89
|
if ((i_mm->t->flag & MM_LOCK) && mlock(i_mm->t->addr, len) == -1) {
|
88
90
|
return with_exception(rb_eArgError, "mlock(%d)", errno);
|
89
91
|
}
|
data/lib/fast_mmaped_file.bundle
CHANGED
Binary file
|