boost - async_read_some of asio::stream_descriptor for file description from inotify_init() failed -
i'm writing asynchronous file monitoring program using boost::asio, based on project: https://github.com/kvikas/file-monitor-service/tree/master/inotify
this project uses boost::asio::posix::stream_descriptor asynchronous reading file descriptor returned inotify_init1(in_nonblock)
unfortunately, when rewrite project, method async_read_some of stream_descriptor in program call completion handler several times (including event: open, access, modify) first change in monitored file.
the next time change monitored file, method async_monitor called again, completion handler not called anymore.
i checked arguments passed in method aync_read_some: handler ok, description initify_init() still open.
could me explain why completion handler not called anymore??? or provide me reasons why method async_read_some not success!
my code following:
template<typename monitor_handler> void async_monitor(monitor_handler handler) { input_->async_read_some(boost::asio::buffer(buffer_), boost::bind(&dir_monitor_impl::handle_monitor<monitor_handler>, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred, handler)); } template<typename monitor_handler> void handle_monitor(const boost::system::error_code &ec, std::size_t bytes_transferred, monitor_handler handler) { std::cout<<"handle_monitor called"<<std::endl; if (!ec) { //process buffer async_monitor(handler);//async_monitor again }else{ std::cout<<"error @ handle_monitor"<<std::endl; } }
Comments
Post a Comment