Revision 95f490de
b/Ganeti/Luxi.hs | ||
---|---|---|
146 | 146 |
let _recv obuf = do |
147 | 147 |
nbuf <- withTimeout queryTimeout "reading luxi response" $ |
148 | 148 |
S.recv (socket s) 4096 |
149 |
let (msg, remaining) = break (eOM ==) (obuf ++ nbuf)
|
|
149 |
let (msg, remaining) = break (eOM ==) nbuf
|
|
150 | 150 |
(if null remaining |
151 |
then _recv msg
|
|
152 |
else return (msg, tail remaining)) |
|
151 |
then _recv (obuf ++ msg)
|
|
152 |
else return (obuf ++ msg, tail remaining))
|
|
153 | 153 |
cbuf <- readIORef $ rbuf s |
154 |
(msg, nbuf) <- _recv cbuf |
|
154 |
let (imsg, ibuf) = break (eOM ==) cbuf |
|
155 |
(msg, nbuf) <- |
|
156 |
(if null ibuf -- if old buffer didn't contain a full message |
|
157 |
then _recv cbuf -- then we read from network |
|
158 |
else return (imsg, tail ibuf)) -- else we return data from our buffer |
|
155 | 159 |
writeIORef (rbuf s) nbuf |
156 | 160 |
return msg |
157 | 161 |
|
Also available in: Unified diff