-- | Lazily stream a 'BSL.ByteString'
bslToArchive :: BSL.ByteString -> IO (Ptr Archive)
bslToArchive bs = do
a <- archive_read_new
void $ archive_read_support_format_all a
bsChunksRef <- newIORef bsChunks
rc <- mkReadCallback (readBSL bsChunksRef)
cc <- mkCloseCallback (\_ ptr -> free ptr $> archiveOk)
nothingPtr <- mallocBytes 0
sequence_ [ archive_read_set_read_callback a rc
, archive_read_set_close_callback a cc
, archive_read_set_callback_data a nothingPtr
-- this is where it hangs indefinitely
, archive_read_open1 a
]
pure a
where readBSL bsRef _ _ dataPtr = do
bs' <- readIORef bsRef
case bs' of
[] -> pure 0
(x:_) -> do
modifyIORef bsRef tail
useAsCStringLen x $ \(charPtr, sz) ->
poke dataPtr charPtr $>
fromIntegral sz
bsChunks = BSL.toChunks bs
Upon further investigation, it appears that the Haskell functions
to create function pointers are somehow fucked (hence the
indefinite hanging with no CPU use). Thus, I do not believe it is
triggered by any infinite loop in archive_read_open1 itself.
Cheers,
Vanessa McHale
--
You received this message because you are subscribed to the Google Groups "libarchive-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libarchive-disc...@googlegroups.com.
To post to this group, send email to libarchiv...@googlegroups.com.
Visit this group at https://groups.google.com/group/libarchive-discuss.
For more options, visit https://groups.google.com/d/optout.