[Pkg-ocaml-maint-commits] [SCM] Cooperative light-weight thread library for OCaml branch, master, updated. debian/2.3.0-3-6-gac63223
Stephane Glondu
steph at glondu.net
Thu Jul 28 21:04:35 UTC 2011
The following commit has been merged in the master branch:
commit da76347089295d19a083353501bc484e45d69e87
Author: Stephane Glondu <steph at glondu.net>
Date: Thu Jul 28 13:26:31 2011 +0200
Cherry-pick two additional patches from upstream
diff --git a/debian/patches/0002-fix-a-race-condition-in-Lwt_io.patch b/debian/patches/0002-fix-a-race-condition-in-Lwt_io.patch
new file mode 100644
index 0000000..2dac1fe
--- /dev/null
+++ b/debian/patches/0002-fix-a-race-condition-in-Lwt_io.patch
@@ -0,0 +1,121 @@
+From: Jeremie Dimino <jeremie at dimino.org>
+Date: Thu, 28 Jul 2011 13:23:03 +0200
+Subject: fix a race condition in Lwt_io
+
+Origin: http://ocsigen.org/darcsweb/?r=lwt;a=commit;h=20110718145731-c41ad-7ced2812fef6069e83864996a274e5e55db1aaf4.gz
+---
+ src/unix/lwt_io.ml | 30 ++++++++++++++++++------------
+ 1 files changed, 18 insertions(+), 12 deletions(-)
+
+diff --git a/src/unix/lwt_io.ml b/src/unix/lwt_io.ml
+index ce2b36c..28d8935 100644
+--- a/src/unix/lwt_io.ml
++++ b/src/unix/lwt_io.ml
+@@ -58,6 +58,9 @@ type 'mode state =
+ (* An atomic operations is being performed on the channel. The
+ argument is the temporary atomic wrapper. *)
+
++ | Waiting_for_busy
++ (* A queued operation has not yet started. *)
++
+ | Idle
+ (* The channel is unused *)
+
+@@ -169,7 +172,7 @@ let is_busy ch =
+ raise (invalid_channel ch.channel)
+ | Idle | Closed ->
+ false
+- | Busy_primitive | Busy_atomic _ ->
++ | Busy_primitive | Busy_atomic _ | Waiting_for_busy ->
+ true
+
+ (* Flush/refill the buffer. No race condition could happen because
+@@ -226,7 +229,7 @@ let perform_io ch = match ch.main.state with
+ | Invalid ->
+ raise_lwt (invalid_channel ch)
+
+- | Idle ->
++ | Idle | Waiting_for_busy ->
+ assert false
+
+ let refill = perform_io
+@@ -259,7 +262,7 @@ let auto_flush oc =
+ lwt () = Lwt.pause () in
+ let wrapper = deepest_wrapper oc in
+ match wrapper.state with
+- | Busy_primitive ->
++ | Busy_primitive | Waiting_for_busy ->
+ (* The channel is used, cancel auto flushing. It will be
+ restarted when the channel returns to the [Idle] state: *)
+ oc.auto_flushing <- false;
+@@ -287,9 +290,12 @@ let auto_flush oc =
+
+ let unlock wrapper = match wrapper.state with
+ | Busy_primitive | Busy_atomic _ ->
+- wrapper.state <- Idle;
+- if not (Lwt_sequence.is_empty wrapper.queued) then
+- wakeup_later (Lwt_sequence.take_l wrapper.queued) ();
++ if Lwt_sequence.is_empty wrapper.queued then
++ wrapper.state <- Idle
++ else begin
++ wrapper.state <- Waiting_for_busy;
++ wakeup_later (Lwt_sequence.take_l wrapper.queued) ()
++ end;
+ (* Launches the auto-flusher: *)
+ let ch = wrapper.channel in
+ if (* Launch the auto-flusher only if the channel is not busy: *)
+@@ -309,7 +315,7 @@ let unlock wrapper = match wrapper.state with
+ if not (Lwt_sequence.is_empty wrapper.queued) then
+ wakeup_later (Lwt_sequence.take_l wrapper.queued) ()
+
+- | Idle ->
++ | Idle | Waiting_for_busy ->
+ (* We must never unlock an unlocked channel *)
+ assert false
+
+@@ -323,7 +329,7 @@ let primitive f wrapper = match wrapper.state with
+ unlock wrapper;
+ return ()
+
+- | Busy_primitive | Busy_atomic _ ->
++ | Busy_primitive | Busy_atomic _ | Waiting_for_busy ->
+ let (res, w) = task () in
+ let node = Lwt_sequence.add_r w wrapper.queued in
+ Lwt.on_cancel res (fun _ -> Lwt_sequence.remove node);
+@@ -334,7 +340,7 @@ let primitive f wrapper = match wrapper.state with
+ unlock wrapper;
+ raise_lwt (closed_channel wrapper.channel)
+
+- | Idle ->
++ | Idle | Waiting_for_busy ->
+ wrapper.state <- Busy_primitive;
+ try_lwt
+ f wrapper.channel
+@@ -370,7 +376,7 @@ let atomic f wrapper = match wrapper.state with
+ unlock wrapper;
+ return ()
+
+- | Busy_primitive | Busy_atomic _ ->
++ | Busy_primitive | Busy_atomic _ | Waiting_for_busy ->
+ let (res, w) = task () in
+ let node = Lwt_sequence.add_r w wrapper.queued in
+ Lwt.on_cancel res (fun _ -> Lwt_sequence.remove node);
+@@ -381,7 +387,7 @@ let atomic f wrapper = match wrapper.state with
+ unlock wrapper;
+ raise_lwt (closed_channel wrapper.channel)
+
+- | Idle ->
++ | Idle | Waiting_for_busy ->
+ let tmp_wrapper = { state = Idle;
+ channel = wrapper.channel;
+ queued = Lwt_sequence.create () } in
+@@ -415,7 +421,7 @@ let rec abort wrapper = match wrapper.state with
+ Lazy.force wrapper.channel.close
+ | Invalid ->
+ raise_lwt (invalid_channel wrapper.channel)
+- | Idle | Busy_primitive ->
++ | Idle | Busy_primitive | Waiting_for_busy ->
+ wrapper.state <- Closed;
+ (* Abort any current real reading/writing operation on the
+ channel: *)
+--
diff --git a/debian/patches/0003-fix-data-corruption-in-Lwt_io.patch b/debian/patches/0003-fix-data-corruption-in-Lwt_io.patch
new file mode 100644
index 0000000..041d278
--- /dev/null
+++ b/debian/patches/0003-fix-data-corruption-in-Lwt_io.patch
@@ -0,0 +1,23 @@
+From: Pierre Chambart <chambart at crans.org>
+Date: Thu, 28 Jul 2011 13:25:03 +0200
+Subject: fix data corruption in Lwt_io.
+
+Origin: http://ocsigen.org/darcsweb/?r=lwt;a=commit;h=20110728095212-0cb73-a111bbba9fba3d4be6c0585ff823c41417f02570.gz
+---
+ src/unix/lwt_unix_stubs.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/src/unix/lwt_unix_stubs.c b/src/unix/lwt_unix_stubs.c
+index e40196c..1adbaea 100644
+--- a/src/unix/lwt_unix_stubs.c
++++ b/src/unix/lwt_unix_stubs.c
+@@ -126,7 +126,7 @@ void lwt_unix_not_available(char const *feature)
+
+ CAMLprim value lwt_unix_blit_bytes_bytes(value val_buf1, value val_ofs1, value val_buf2, value val_ofs2, value val_len)
+ {
+- memcpy((char*)Caml_ba_data_val(val_buf2) + Long_val(val_ofs2),
++ memmove((char*)Caml_ba_data_val(val_buf2) + Long_val(val_ofs2),
+ (char*)Caml_ba_data_val(val_buf1) + Long_val(val_ofs1),
+ Long_val(val_len));
+ return Val_unit;
+--
diff --git a/debian/patches/series b/debian/patches/series
index 97db22b..3261106 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
0001-Do-not-build-manual-manual.pdf.patch
+0002-fix-a-race-condition-in-Lwt_io.patch
+0003-fix-data-corruption-in-Lwt_io.patch
--
Cooperative light-weight thread library for OCaml
More information about the Pkg-ocaml-maint-commits
mailing list