1 |
gienah 14/07/03 13:11:08 |
2 |
|
3 |
Added: darcs-2.8.4-ghc-7.8-part-2.patch |
4 |
darcs-2.8.4-issue2364.patch |
5 |
darcs-2.8.4-fix-nonatomic-global.patch |
6 |
darcs-2.8.4-issue2364-part-2.patch |
7 |
Log: |
8 |
Update darcs-2.8.4-r6 from the gentoo-haskell overlay so it will build with recent haskell packages and ghc 7.8 |
9 |
|
10 |
(Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key 618E971F) |
11 |
|
12 |
Revision Changes Path |
13 |
1.1 dev-vcs/darcs/files/darcs-2.8.4-ghc-7.8-part-2.patch |
14 |
|
15 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/darcs/files/darcs-2.8.4-ghc-7.8-part-2.patch?rev=1.1&view=markup |
16 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/darcs/files/darcs-2.8.4-ghc-7.8-part-2.patch?rev=1.1&content-type=text/plain |
17 |
|
18 |
Index: darcs-2.8.4-ghc-7.8-part-2.patch |
19 |
=================================================================== |
20 |
diff --git a/src/Darcs/Test/Patch.hs b/src/Darcs/Test/Patch.hs |
21 |
index 0f7ed24..078fbc3 100644 |
22 |
--- a/src/Darcs/Test/Patch.hs |
23 |
+++ b/src/Darcs/Test/Patch.hs |
24 |
@@ -2,6 +2,9 @@ |
25 |
#if __GLASGOW_HASKELL__ >= 700 |
26 |
{-# LANGUAGE ImpredicativeTypes #-} |
27 |
#endif |
28 |
+#if __GLASGOW_HASKELL__ >= 708 |
29 |
+{-# LANGUAGE AllowAmbiguousTypes #-} |
30 |
+#endif |
31 |
-- Copyright (C) 2002-2005,2007 David Roundy |
32 |
-- |
33 |
-- This program is free software; you can redistribute it and/or modify |
34 |
|
35 |
|
36 |
|
37 |
1.1 dev-vcs/darcs/files/darcs-2.8.4-issue2364.patch |
38 |
|
39 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/darcs/files/darcs-2.8.4-issue2364.patch?rev=1.1&view=markup |
40 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/darcs/files/darcs-2.8.4-issue2364.patch?rev=1.1&content-type=text/plain |
41 |
|
42 |
Index: darcs-2.8.4-issue2364.patch |
43 |
=================================================================== |
44 |
* resolve issue2364: fix file corruption on double fetch |
45 |
|
46 |
The bug is the result of attempt to fetch the same file |
47 |
(say F) by the same URL (U) multiple times concurrently. |
48 |
|
49 |
First time U gets fetched by speculative prefetch logic. |
50 |
Second time as an ordinary file (while first fetch is not finished). |
51 |
|
52 |
The function 'copyUrlWithPriority' sends download request |
53 |
to 'urlChan' both times (it's already not a nice situation, |
54 |
fixed by this patch). |
55 |
|
56 |
Later urlThread satisfies first request, notifies receiver, |
57 |
and starts downloading exactly the same U again. |
58 |
|
59 |
I don't know exact data corruption mechanics yet, but it has |
60 |
to do with non-random intermediate file names of downloaded |
61 |
files and 'truncate' call when temp file is opened for a new |
62 |
downlaod job. |
63 |
|
64 |
All temp names are completely non-random for a single darcs run: |
65 |
|
66 |
urlThread :: Chan UrlRequest -> IO () |
67 |
urlThread ch = do |
68 |
junk <- flip showHex "" `fmap` randomRIO rrange |
69 |
evalStateT urlThread' (UrlState Map.empty emptyQ 0 junk) |
70 |
|
71 |
createDownloadFileName :: FilePath -> UrlState -> FilePath |
72 |
createDownloadFileName f st = f ++ "-new_" ++ randomJunk st |
73 |
|
74 |
My theory is next download manages to step on toes of previous job. |
75 |
|
76 |
I'll try to make file names truly random in other patch. |
77 |
That way such errors should manifest as read erros instead of data |
78 |
corruption. |
79 |
|
80 |
Thanks! |
81 |
diff --git a/src/URL.hs b/src/URL.hs |
82 |
index 4cb85ee..26de278 100644 |
83 |
--- a/src/URL.hs |
84 |
+++ b/src/URL.hs |
85 |
@@ -18,11 +18,12 @@ module URL ( copyUrl, copyUrlFirst, setDebugHTTP, |
86 |
import Data.IORef ( newIORef, readIORef, writeIORef, IORef ) |
87 |
import Data.Map ( Map ) |
88 |
import qualified Data.Map as Map |
89 |
+import Data.Tuple ( swap ) |
90 |
import System.Directory ( copyFile ) |
91 |
import System.IO.Unsafe ( unsafePerformIO ) |
92 |
import Control.Concurrent ( forkIO ) |
93 |
import Control.Concurrent.Chan ( isEmptyChan, newChan, readChan, writeChan, Chan ) |
94 |
-import Control.Concurrent.MVar ( isEmptyMVar, modifyMVar_, newEmptyMVar, newMVar, putMVar, readMVar, withMVar, MVar ) |
95 |
+import Control.Concurrent.MVar ( isEmptyMVar, modifyMVar, modifyMVar_, newEmptyMVar, newMVar, putMVar, readMVar, withMVar, MVar ) |
96 |
import Control.Monad ( unless, when ) |
97 |
import Control.Monad.Trans ( liftIO ) |
98 |
import Control.Monad.State ( evalStateT, get, modify, put, StateT ) |
99 |
@@ -196,10 +197,10 @@ copyUrlWithPriority p u f c = do |
100 |
debugMessage ("URL.copyUrlWithPriority ("++u++"\n"++ |
101 |
" -> "++f++")") |
102 |
v <- newEmptyMVar |
103 |
- let fn _ old_val = old_val |
104 |
- modifyMVar_ urlNotifications (return . (Map.insertWith fn u v)) |
105 |
- let r = UrlRequest u f c p |
106 |
- writeChan urlChan r |
107 |
+ old_mv <- modifyMVar urlNotifications (return . swap . Map.insertLookupWithKey (\_k _n old -> old) u v) |
108 |
+ case old_mv of |
109 |
+ Nothing -> writeChan urlChan $ UrlRequest u f c p -- ok, new URL |
110 |
+ Just _ -> debugMessage $ "URL.copyUrlWithPriority already in progress, skip (" ++ u ++ "\n" ++ "-> " ++ f ++ ")" |
111 |
|
112 |
waitNextUrl :: StateT UrlState IO () |
113 |
waitNextUrl = do |
114 |
|
115 |
|
116 |
|
117 |
1.1 dev-vcs/darcs/files/darcs-2.8.4-fix-nonatomic-global.patch |
118 |
|
119 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/darcs/files/darcs-2.8.4-fix-nonatomic-global.patch?rev=1.1&view=markup |
120 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/darcs/files/darcs-2.8.4-fix-nonatomic-global.patch?rev=1.1&content-type=text/plain |
121 |
|
122 |
Index: darcs-2.8.4-fix-nonatomic-global.patch |
123 |
=================================================================== |
124 |
There is a bug in speculateFileOrUrl. |
125 |
It puts downloaded file nonatomically. |
126 |
|
127 |
There is a window when copyFileOrUrl can (and does) |
128 |
copy partially downloaded file. |
129 |
|
130 |
Darcs-bug: http://bugs.darcs.net/issue2364 |
131 |
diff --git a/src/Darcs/External.hs b/src/Darcs/External.hs |
132 |
index 2e0e791..d5a0b9f 100644 |
133 |
--- a/src/Darcs/External.hs |
134 |
+++ b/src/Darcs/External.hs |
135 |
@@ -184,7 +184,7 @@ copyFileOrUrl rd fou out _ | isSshUrl fou = copySSH rd (splitSshUrl fou) |
136 |
copyFileOrUrl _ fou _ _ = fail $ "unknown transport protocol: " ++ fou |
137 |
|
138 |
speculateFileOrUrl :: String -> FilePath -> IO () |
139 |
-speculateFileOrUrl fou out | isHttpUrl fou = speculateRemote fou out |
140 |
+speculateFileOrUrl fou out | isHttpUrl fou = speculateRemote fou out >> waitUrl fou |
141 |
| otherwise = return () |
142 |
|
143 |
copyLocal :: String -> FilePath -> IO () |
144 |
|
145 |
|
146 |
|
147 |
1.1 dev-vcs/darcs/files/darcs-2.8.4-issue2364-part-2.patch |
148 |
|
149 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/darcs/files/darcs-2.8.4-issue2364-part-2.patch?rev=1.1&view=markup |
150 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/darcs/files/darcs-2.8.4-issue2364-part-2.patch?rev=1.1&content-type=text/plain |
151 |
|
152 |
Index: darcs-2.8.4-issue2364-part-2.patch |
153 |
=================================================================== |
154 |
Tue May 13 22:07:19 FET 2014 Sergei Trofimovich <slyfox@×××××××××××××××××.org> |
155 |
* resolve issue2364: don't break list of 'bad sources' |
156 |
|
157 |
This time the bug manifested on a simple operation: |
158 |
$ darcs record -a -m "something" |
159 |
|
160 |
Attempt to write a patch resulted in something like: |
161 |
Failed to record patch 'hello' |
162 |
|
163 |
HINT: I could not reach the following repositories: |
164 |
http://repetae.net/repos/jhc |
165 |
/home/st/.darcs/cache |
166 |
/home/st/.cache/darcs |
167 |
/home/st/dev/darcs/jhc |
168 |
If you're not using them, you should probably delete |
169 |
|
170 |
The sequence should be the following: |
171 |
1. store patch to inventory/foo |
172 |
2. try to store to a writable cache (say, ~/.darcs/cache/patches) |
173 |
3. fail to write |
174 |
4. filter out bad caches |
175 |
5. try again |
176 |
6. copy from cache to patches/ |
177 |
|
178 |
Due to missing NOINLINE step 4. led to |
179 |
all caches treated as writable, thus step 5 |
180 |
failed without a chance for patch to |
181 |
go to 'patches/'. |
182 |
|
183 |
As a side-effect building darcs with -O0 produced seemingly working darcs. |
184 |
Reported-by: Ivan Miljenovic |
185 |
diff -rN -u old-darcs.net/src/Darcs/Util/Global.hs new-darcs.net/src/Darcs/Util/Global.hs |
186 |
--- old-darcs.net/src/Darcs/Global.hs 2014-05-13 22:23:29.897329750 +0300 |
187 |
+++ new-darcs.net/src/Darcs/Global.hs 2014-05-13 22:23:29.979329754 +0300 |
188 |
@@ -135,7 +135,7 @@ |
189 |
|
190 |
_badSourcesList :: IORef [String] |
191 |
_badSourcesList = unsafePerformIO $ newIORef [] |
192 |
-{- NOINLINE _badSourcesList -} |
193 |
+{-# NOINLINE _badSourcesList #-} |
194 |
|
195 |
|
196 |
addBadSource :: String -> IO () |
197 |
@@ -154,7 +154,7 @@ |
198 |
|
199 |
_reachableSourcesList :: IORef [String] |
200 |
_reachableSourcesList = unsafePerformIO $ newIORef [] |
201 |
-{- NOINLINE _reachableSourcesList -} |
202 |
+{-# NOINLINE _reachableSourcesList #-} |
203 |
|
204 |
|
205 |
addReachableSource :: String -> IO () |