Skip to content

Commit

Permalink
Merge pull request #166 from phile314/cb_ints
Browse files Browse the repository at this point in the history
Fix stats/socket callback types
  • Loading branch information
AlexeyRaga authored Jan 5, 2021
2 parents 92a44af + 1f5287e commit 5049adb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Kafka/Internal/RdKafka.chs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ rdKafkaConfSetLogCb conf cb = do
withForeignPtr conf $ \c -> rdKafkaConfSetLogCb' c cb'

---- Stats Callback
type StatsCallback' = Ptr RdKafkaT -> CString -> CSize -> Word8Ptr -> IO ()
type StatsCallback' = Ptr RdKafkaT -> CString -> CSize -> Word8Ptr -> IO CInt
type StatsCallback = Ptr RdKafkaT -> ByteString -> IO ()

foreign import ccall safe "wrapper"
Expand All @@ -426,12 +426,12 @@ foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_stats_cb"

rdKafkaConfSetStatsCb :: RdKafkaConfTPtr -> StatsCallback -> IO ()
rdKafkaConfSetStatsCb conf cb = do
cb' <- mkStatsCallback $ \k j jl _ -> BS.packCStringLen (j, cIntConv jl) >>= cb k
cb' <- mkStatsCallback $ \k j jl _ -> BS.packCStringLen (j, cIntConv jl) >>= cb k >> pure 0
withForeignPtr conf $ \c -> rdKafkaConfSetStatsCb' c cb'
return ()

---- Socket Callback
type SocketCallback = Int -> Int -> Int -> Word8Ptr -> IO ()
type SocketCallback = Int -> Int -> Int -> Word8Ptr -> IO CInt

foreign import ccall safe "wrapper"
mkSocketCallback :: SocketCallback -> IO (FunPtr SocketCallback)
Expand All @@ -442,7 +442,7 @@ foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_socket_cb"
rdKafkaConfSetSocketCb :: RdKafkaConfTPtr -> SocketCallback -> IO ()
rdKafkaConfSetSocketCb conf cb = do
cb' <- mkSocketCallback cb
withForeignPtr conf $ \c -> rdKafkaConfSetSocketCb' c cb'
withForeignPtr conf $ \c -> rdKafkaConfSetSocketCb' c cb' >> pure 0
return ()

{#fun rd_kafka_conf_set_opaque as ^
Expand Down

0 comments on commit 5049adb

Please sign in to comment.