diff options
author | Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr> | 2012-02-18 09:36:13 +0000 |
---|---|---|
committer | Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr> | 2012-02-18 09:36:13 +0000 |
commit | b2cbd03b35e25ff4afb67f6c7f217039709405d8 (patch) | |
tree | cfa4adcdaf313553d6c70ba3701aa0b012062ab2 /stdlib/queue.ml | |
parent | 62fc590a47cde5e5a07b934ff0d664899a2df2a0 (diff) |
Fix PR#5309: Queue.add is not thread/signal safe
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12163 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib/queue.ml')
-rw-r--r-- | stdlib/queue.ml | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/stdlib/queue.ml b/stdlib/queue.ml index 4e12eb3d2..388a46c53 100644 --- a/stdlib/queue.ml +++ b/stdlib/queue.ml @@ -54,12 +54,12 @@ let clear q = q.tail <- Obj.magic None let add x q = - q.length <- q.length + 1; - if q.length = 1 then + if q.length = 0 then let rec cell = { content = x; next = cell } in + q.length <- 1; q.tail <- cell else let tail = q.tail in @@ -68,6 +68,7 @@ let add x q = content = x; next = head } in + q.length <- q.length + 1; tail.next <- cell; q.tail <- cell |