prometheus-client-mmap 0.7.0.beta45.6 → 0.7.0.beta45.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 160da09544b8a969ae7ac75b07989ddc8a24cfd6
4
- data.tar.gz: 6a081732b114b02fd4f07cab0c07bc68dfc1b368
3
+ metadata.gz: 7f9ed8e64e915588572b1eec01daf8cc1fe0b12f
4
+ data.tar.gz: 3ff520858018c2b87c5530b169b8c06d4ac3644e
5
5
  SHA512:
6
- metadata.gz: 3d2f202559dd3b8ca8e3b9a66778e78842c69d627dce23e3fe94ab3600d5bd44365539697b5c063ba86a52cf26279e90d455538a3e6825ec6c19523b153e3ccc
7
- data.tar.gz: 6d5664c82e8b6027553ffef56524f4505d6fb8ae5d60f817d9a0e4153b1501d19b88e1373d950c3aca707f06160c5bbd58cad35a7ca8491a18ba966432a7b4dc
6
+ metadata.gz: 51c868831e62e61ecd98f78f60f84e4e8e5e1c1662c0275fe54d49d632615431e39f76e9073baca0c78d4597e17d73a3c6f0efd9554bfcd93e3f0aada43b83da
7
+ data.tar.gz: dd9c23e607e733ba2eb60043e8b5a411cb8b5e0342b2349983fb51c9f65ff3cb4205b086bdbc8121aa618d77c7f52feb058ec5c965c224bac8d769aaf053b3a9
@@ -119,6 +119,7 @@ static void mm_free(mm_ipc *i_mm) {
119
119
  if (i_mm->t->path) {
120
120
  if (munmap(i_mm->t->addr, i_mm->t->len) != 0) {
121
121
  if (i_mm->t->path != (char *)-1 && i_mm->t->path != NULL) {
122
+ close(i_mm->t->fd);
122
123
  free(i_mm->t->path);
123
124
  }
124
125
  free(i_mm);
@@ -133,6 +134,7 @@ static void mm_free(mm_ipc *i_mm) {
133
134
  free(i_mm);
134
135
  rb_raise(rb_eTypeError, "truncate");
135
136
  }
137
+ close(i_mm->t->fd);
136
138
  free(i_mm->t->path);
137
139
  }
138
140
  }
@@ -225,16 +227,19 @@ VALUE mm_init(VALUE obj, VALUE fname) {
225
227
  size = i_mm->t->incr;
226
228
  }
227
229
 
228
- addr = mmap(0, size, pmode, vscope, fd, offset);
229
- close(fd);
230
+ addr = mmap(0, size, pmode, vscope, fd, offset);
230
231
 
231
232
  if (addr == MAP_FAILED || !addr) {
233
+ close(fd);
232
234
  rb_raise(rb_eArgError, "mmap failed (%d)", errno);
233
235
  }
234
236
 
237
+ i_mm->t->fd = fd;
235
238
  i_mm->t->addr = addr;
236
239
  i_mm->t->len = size;
237
- if (!init) i_mm->t->real = size;
240
+ if (!init) {
241
+ i_mm->t->real = size;
242
+ }
238
243
  i_mm->t->pmode = pmode;
239
244
  i_mm->t->vscope = vscope;
240
245
  i_mm->t->smode = smode & ~O_TRUNC;
@@ -312,7 +317,9 @@ VALUE mm_unmap(VALUE obj) {
312
317
  if (i_mm->t->path) {
313
318
  if (munmap(i_mm->t->addr, i_mm->t->len) != 0) {
314
319
  if (i_mm->t->path != (char *)-1 && i_mm->t->path != NULL) {
320
+ close(i_mm->t->fd);
315
321
  free(i_mm->t->path);
322
+ i_mm->t->fd = -1;
316
323
  i_mm->t->path = NULL;
317
324
  }
318
325
 
@@ -324,8 +331,10 @@ VALUE mm_unmap(VALUE obj) {
324
331
  truncate(i_mm->t->path, i_mm->t->real) == -1) {
325
332
  rb_raise(rb_eTypeError, "truncate");
326
333
  }
334
+ close(i_mm->t->fd);
327
335
  free(i_mm->t->path);
328
336
  }
337
+ i_mm->t->fd = -1;
329
338
  i_mm->t->path = NULL;
330
339
  }
331
340
  return Qnil;
@@ -31,6 +31,7 @@ typedef struct {
31
31
  size_t len, real, incr;
32
32
  off_t offset;
33
33
  char *path, *template;
34
+ int fd;
34
35
  } mm_mmap;
35
36
 
36
37
  typedef struct {
@@ -39,6 +39,10 @@ static void expand(mm_ipc *i_mm, size_t len) {
39
39
  rb_raise(rb_eArgError, "munmap failed");
40
40
  }
41
41
 
42
+ if (i_mm->t->fd > 0 && close(i_mm->t->fd)){
43
+ rb_raise(rb_eArgError, "Closing mmaped fd failed with %d", errno);
44
+ }
45
+
42
46
  int fd = open_and_extend_file(i_mm, len);
43
47
 
44
48
  i_mm->t->addr = mmap(0, len, i_mm->t->pmode, i_mm->t->vscope, fd, i_mm->t->offset);
@@ -48,13 +52,12 @@ static void expand(mm_ipc *i_mm, size_t len) {
48
52
  rb_raise(rb_eArgError, "mmap failed");
49
53
  }
50
54
 
51
- if (close(fd) == -1) {
52
- rb_raise(rb_eArgError, "Can't close %s", i_mm->t->path);
53
- }
54
-
55
55
  if ((i_mm->t->flag & MM_LOCK) && mlock(i_mm->t->addr, len) == -1) {
56
+ close(fd);
56
57
  rb_raise(rb_eArgError, "mlock(%d)", errno);
57
58
  }
59
+
60
+ i_mm->t->fd = fd;
58
61
  i_mm->t->len = len;
59
62
  i_mm->t->real = len;
60
63
  }
Binary file
@@ -1,5 +1,5 @@
1
1
  module Prometheus
2
2
  module Client
3
- VERSION = '0.7.0.beta45.6'.freeze
3
+ VERSION = '0.7.0.beta45.7'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus-client-mmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.beta45.6
4
+ version: 0.7.0.beta45.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schmidt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-29 00:00:00.000000000 Z
12
+ date: 2018-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fuzzbert