SHARE
TWEET

Untitled

a guest Feb 16th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From c66a374a6fee31dd86d627ae83ac36d9717091b9 Mon Sep 17 00:00:00 2001
  2. From: Jeremie Dimino <jdimino@janestreet.com>
  3. Date: Mon, 15 Jul 2013 11:54:18 +0100
  4. Subject: [PATCH] release the runtime system when calling caml_dlopen
  5.  
  6. ---
  7.  asmrun/natdynlink.c | 14 ++++++++++++--
  8.  byterun/dynlink.c   |  9 ++++++++-
  9.  2 files changed, 20 insertions(+), 3 deletions(-)
  10.  
  11. diff --git a/asmrun/natdynlink.c b/asmrun/natdynlink.c
  12. index ebe5d34..e85c57e 100644
  13. --- a/asmrun/natdynlink.c
  14. +++ b/asmrun/natdynlink.c
  15. @@ -51,10 +51,15 @@ CAMLprim value caml_natdynlink_open(value filename, value global)
  16.    CAMLlocal1 (res);
  17.    void *sym;
  18.    void *handle;
  19. +  char *p;
  20.  
  21.    /* TODO: dlclose in case of error... */
  22.  
  23. -  handle = caml_dlopen(String_val(filename), 1, Int_val(global));
  24. +  p = caml_strdup(String_val(filename));
  25. +  caml_enter_blocking_section();
  26. +  handle = caml_dlopen(p, 1, Int_val(global));
  27. +  caml_leave_blocking_section();
  28. +  caml_stat_free(p);
  29.  
  30.    if (NULL == handle)
  31.      CAMLreturn(caml_copy_string(caml_dlerror()));
  32. @@ -117,10 +122,15 @@ CAMLprim value caml_natdynlink_run_toplevel(value filename, value symbol)
  33.    CAMLparam2 (filename, symbol);
  34.    CAMLlocal2 (res, v);
  35.    void *handle;
  36. +  char *p;
  37.  
  38.    /* TODO: dlclose in case of error... */
  39.  
  40. -  handle = caml_dlopen(String_val(filename), 1, 1);
  41. +  p = caml_strdup(String_val(filename));
  42. +  caml_enter_blocking_section();
  43. +  handle = caml_dlopen(p, 1, 1);
  44. +  caml_leave_blocking_section();
  45. +  caml_stat_free(p);
  46.  
  47.    if (NULL == handle) {
  48.      res = caml_alloc(1,1);
  49. diff --git a/byterun/dynlink.c b/byterun/dynlink.c
  50. index c35c8ef..9952344 100644
  51. --- a/byterun/dynlink.c
  52. +++ b/byterun/dynlink.c
  53. @@ -119,7 +119,9 @@ static void open_shared_lib(char * name)
  54.    realname = caml_search_dll_in_path(&caml_shared_libs_path, name);
  55.    caml_gc_message(0x100, "Loading shared library %s\n",
  56.                    (uintnat) realname);
  57. +  caml_enter_blocking_section();
  58.    handle = caml_dlopen(realname, 1, 1);
  59. +  caml_leave_blocking_section();
  60.    if (handle == NULL)
  61.      caml_fatal_error_arg2("Fatal error: cannot load shared library %s\n", name,
  62.                            "Reason: %s\n", caml_dlerror());
  63. @@ -202,10 +204,15 @@ CAMLprim value caml_dynlink_open_lib(value mode, value filename)
  64.  {
  65.    void * handle;
  66.    value result;
  67. +  char * p;
  68.  
  69.    caml_gc_message(0x100, "Opening shared library %s\n",
  70.                    (uintnat) String_val(filename));
  71. -  handle = caml_dlopen(String_val(filename), Int_val(mode), 1);
  72. +  p = caml_strdup(String_val(filename));
  73. +  caml_enter_blocking_section();
  74. +  handle = caml_dlopen(p, Int_val(mode), 1);
  75. +  caml_leave_blocking_section();
  76. +  caml_stat_free(p);
  77.    if (handle == NULL) caml_failwith(caml_dlerror());
  78.    result = caml_alloc_small(1, Abstract_tag);
  79.    Handle_val(result) = handle;
  80. --
  81. 1.8.3.1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top