Skip to content

Commit

Permalink
librados: warn about rados_watch_flush() prior to ioctx shutdown
Browse files Browse the repository at this point in the history
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed Dec 22, 2014
1 parent 30678f6 commit 1fbe9b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/include/rados/librados.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ CEPH_RADOS_API int rados_connect(rados_t cluster);
* completed. To do that, you must call rados_aio_flush() on all open
* io contexts.
*
* @warning We implicitly call rados_watch_flush() on shutdown. If
* there are watches being used, this should be done explicitly before
* destroying the relevant IoCtx. We do it here as a safety measure.
*
* @post the cluster handle cannot be used again
*
* @param cluster the cluster to shutdown
Expand Down Expand Up @@ -632,6 +636,12 @@ CEPH_RADOS_API int rados_ioctx_create(rados_t cluster, const char *pool_name,
* writes have completed. You must call rados_aio_flush()
* on the io context before destroying it to do that.
*
* @warning If this ioctx is used by rados_watch, the caller needs to
* be sure that all registered watches are disconnected via
* rados_unwatch() and that rados_watch_flush() is called. This
* ensures that a racing watch callback does not make use of a
* destroyed ioctx.
*
* @param io the io context to dispose of
*/
CEPH_RADOS_API void rados_ioctx_destroy(rados_ioctx_t io);
Expand Down
4 changes: 4 additions & 0 deletions src/include/rados/librados.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,10 @@ namespace librados
* rados.ioctx_create("my_pool", p);
* p->stat(&stats);
* ... etc ...
*
* NOTE: be sure to call watch_flush() prior to destroying any IoCtx
* that is used for watch events to ensure that racing callbacks
* have completed.
*/
class CEPH_RADOS_API IoCtx
{
Expand Down

0 comments on commit 1fbe9b6

Please sign in to comment.