commit 8d288b332b2bece9d0be06d3772d15361f3ecf89 Author: Nathaniel McCallum npmccallum@redhat.com Date: Wed Feb 20 13:01:19 2013 -0500
Make verto_set_flags() a no-op if the flags are not changed.
src/verto.c | 10 ++++++++-- src/verto.h | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) --- diff --git a/src/verto.c b/src/verto.c index b9887ef..b14bc76 100644 --- a/src/verto.c +++ b/src/verto.c @@ -45,6 +45,8 @@ #define _str(s) # s #define __str(s) _str(s)
+#define MUTABLE(flags) (flags & _VERTO_EV_FLAG_MUTABLE_MASK) + /* Remove flags we can emulate */ #define make_actual(flags) ((flags) & ~(VERTO_EV_FLAG_PERSIST|VERTO_EV_FLAG_IO_CLOSE_FD))
@@ -752,8 +754,12 @@ verto_set_flags(verto_ev *ev, verto_ev_flag flags) if (!ev) return;
+ /* No modification is needed, so do nothing. */ + if (MUTABLE(ev->flags) == MUTABLE(flags)) + return; + ev->flags &= ~_VERTO_EV_FLAG_MUTABLE_MASK; - ev->flags |= flags & _VERTO_EV_FLAG_MUTABLE_MASK; + ev->flags |= MUTABLE(flags);
/* If setting flags isn't supported, just rebuild the event */ if (!ev->ctx->module->funcs->ctx_set_flags) { @@ -765,7 +771,7 @@ verto_set_flags(verto_ev *ev, verto_ev_flag flags) }
ev->actual &= ~_VERTO_EV_FLAG_MUTABLE_MASK; - ev->actual |= flags & _VERTO_EV_FLAG_MUTABLE_MASK; + ev->actual |= MUTABLE(flags); ev->ctx->module->funcs->ctx_set_flags(ev->ctx->ctx, ev, ev->ev); }
diff --git a/src/verto.h b/src/verto.h index 5540367..84f21a7 100644 --- a/src/verto.h +++ b/src/verto.h @@ -444,7 +444,8 @@ verto_get_flags(const verto_ev *ev); * Sets the flags associated with the given verto_ev. * * See _VERTO_EV_FLAG_MUTABLE_MASK for the flags that can be changed - * with this function. All others will be ignored. + * with this function. All others will be ignored. If the flags specified + * are the same as the flags the event already has, this function is a no-op. * * @see verto_add_io() * @see verto_add_timeout()
libverto-commits@lists.fedorahosted.org