diff options
author | Mark Shinwell <mshinwell@janestreet.com> | 2010-04-01 07:36:49 +0000 |
---|---|---|
committer | Mark Shinwell <mshinwell@janestreet.com> | 2010-04-01 07:36:49 +0000 |
commit | cf088abef1ac4c55db9e6962ddac416463c14125 (patch) | |
tree | f00c7892a9262ea2a8b27a4e171ef995893e8e87 /otherlibs/unix/lseek.c | |
parent | bed77edf06069a556df1c83791de227d830e3cc3 (diff) |
release runtime lock for lseek (mantis 4801)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10223 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/unix/lseek.c')
-rw-r--r-- | otherlibs/unix/lseek.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/otherlibs/unix/lseek.c b/otherlibs/unix/lseek.c index 6dece9503..cb59bb551 100644 --- a/otherlibs/unix/lseek.c +++ b/otherlibs/unix/lseek.c @@ -39,8 +39,10 @@ static int seek_command_table[] = { CAMLprim value unix_lseek(value fd, value ofs, value cmd) { file_offset ret; + caml_enter_blocking_section(); ret = lseek(Int_val(fd), Long_val(ofs), seek_command_table[Int_val(cmd)]); + caml_leave_blocking_section(); if (ret == -1) uerror("lseek", Nothing); if (ret > Max_long) unix_error(EOVERFLOW, "lseek", Nothing); return Val_long(ret); @@ -49,8 +51,13 @@ CAMLprim value unix_lseek(value fd, value ofs, value cmd) CAMLprim value unix_lseek_64(value fd, value ofs, value cmd) { file_offset ret; - ret = lseek(Int_val(fd), File_offset_val(ofs), - seek_command_table[Int_val(cmd)]); + /* [ofs] is an Int64, which is stored as a custom block; we must therefore + extract its contents before dropping the runtime lock, or it might be + moved. */ + file_offset ofs_c = File_offset_val(ofs); + caml_enter_blocking_section(); + ret = lseek(Int_val(fd), ofs_c, seek_command_table[Int_val(cmd)]); + caml_leave_blocking_section(); if (ret == -1) uerror("lseek", Nothing); return Val_file_offset(ret); } |