bootsnap 1.18.0 → 1.18.1

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
  SHA256:
3
- metadata.gz: 52fa7adde2726e79c8d06b4ca8a450d0ecc0fd143b377a0da3aa27965e5ecd52
4
- data.tar.gz: 7029e821fbd1da561f14fce91cc3ca72f8ee80eb6ead5a099bc37b74233c9dce
3
+ metadata.gz: 69d7ab3b264f447ac2a6a3ccea6a4cb27e6fa0ce6b50e6fef645c21d41a89a07
4
+ data.tar.gz: 595c8df291862a529b9a679f36bcae270c5d0efeee22b2fa68f1d7fc78cd7a86
5
5
  SHA512:
6
- metadata.gz: bce0d723ae15e1fcc8961b698977977a49587d4fe514c76dd10d97453808c6562681e9df80dd3ecec2f1eff70f8a54592027c699d37c4c39e9254c6b63507f6b
7
- data.tar.gz: 8272f4541d3789e8eb390319ec04d202b90fc0745696f73d414a7dc1365380246ec7b44746b3592abf19883eae709f2daf4e5033677b7be3490dc0ad642fb6d7
6
+ metadata.gz: 38b9b648b181ca689c3ed64b5f01ad2bb1f41c0b51f241eed19b9d5b2fc93247b37fef4e507981b3e606f4d4b1840b2c57a0ef9656d36fbc398f14e725549235
7
+ data.tar.gz: e72104154d6b9bd688a2290e1704546e9dd08f792e2bf34d1a02329578e694c9849e79f3f62f197093ab42a06f8328028426cc0676b6c4c2a3a565ebd586bd44
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Unreleased
2
2
 
3
+ # 1.18.1
4
+
5
+ * Handle `EPERM` errors when opening files with `O_NOATIME`.
6
+
3
7
  # 1.18.0
4
8
 
5
9
  * `Bootsnap.instrumentation` now receive `:hit` events.
@@ -96,6 +96,7 @@ static ID instrumentation_method;
96
96
  static VALUE sym_hit, sym_miss, sym_stale, sym_revalidated;
97
97
  static bool instrumentation_enabled = false;
98
98
  static bool readonly = false;
99
+ static bool perm_issue = false;
99
100
 
100
101
  /* Functions exposed as module functions on Bootsnap::CompileCache::Native */
101
102
  static VALUE bs_instrumentation_enabled_set(VALUE self, VALUE enabled);
@@ -119,7 +120,7 @@ static int update_cache_key(struct bs_cache_key *current_key, int cache_fd, cons
119
120
  static void bs_cache_key_digest(struct bs_cache_key * key, const VALUE input_data);
120
121
  static VALUE bs_fetch(char * path, VALUE path_v, char * cache_path, VALUE handler, VALUE args);
121
122
  static VALUE bs_precompile(char * path, VALUE path_v, char * cache_path, VALUE handler);
122
- static int open_current_file(char * path, struct bs_cache_key * key, const char ** errno_provenance);
123
+ static int open_current_file(const char * path, struct bs_cache_key * key, const char ** errno_provenance);
123
124
  static int fetch_cached_data(int fd, ssize_t data_size, VALUE handler, VALUE args, VALUE * output_data, int * exception_tag, const char ** errno_provenance);
124
125
  static uint32_t get_ruby_revision(void);
125
126
  static uint32_t get_ruby_platform(void);
@@ -413,17 +414,34 @@ bs_rb_precompile(VALUE self, VALUE cachedir_v, VALUE path_v, VALUE handler)
413
414
 
414
415
  return bs_precompile(path, path_v, cache_path, handler);
415
416
  }
417
+
418
+ static int bs_open_noatime(const char *path, int flags) {
419
+ int fd = 1;
420
+ if (!perm_issue) {
421
+ fd = open(path, flags | O_NOATIME);
422
+ if (fd < 0 && errno == EPERM) {
423
+ errno = 0;
424
+ perm_issue = true;
425
+ }
426
+ }
427
+
428
+ if (perm_issue) {
429
+ fd = open(path, flags);
430
+ }
431
+ return fd;
432
+ }
433
+
416
434
  /*
417
435
  * Open the file we want to load/cache and generate a cache key for it if it
418
436
  * was loaded.
419
437
  */
420
438
  static int
421
- open_current_file(char * path, struct bs_cache_key * key, const char ** errno_provenance)
439
+ open_current_file(const char * path, struct bs_cache_key * key, const char ** errno_provenance)
422
440
  {
423
441
  struct stat statbuf;
424
442
  int fd;
425
443
 
426
- fd = open(path, O_RDONLY | O_NOATIME);
444
+ fd = bs_open_noatime(path, O_RDONLY);
427
445
  if (fd < 0) {
428
446
  *errno_provenance = "bs_fetch:open_current_file:open";
429
447
  return fd;
@@ -491,9 +509,9 @@ open_cache_file(const char * path, struct bs_cache_key * key, const char ** errn
491
509
  int fd, res;
492
510
 
493
511
  if (readonly) {
494
- fd = open(path, O_RDONLY | O_NOATIME);
512
+ fd = bs_open_noatime(path, O_RDONLY);
495
513
  } else {
496
- fd = open(path, O_RDWR | O_NOATIME);
514
+ fd = bs_open_noatime(path, O_RDWR);
497
515
  }
498
516
 
499
517
  if (fd < 0) {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bootsnap
4
- VERSION = "1.18.0"
4
+ VERSION = "1.18.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootsnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burke Libbey