Re: [systemd-devel] [PATCH] event: clear pending-state when re-arming timers

2013-11-20 Thread Lennart Poettering
On Wed, 20.11.13 07:59, David Herrmann (dh.herrm...@gmail.com) wrote:

 If a timer fires and is marked pending, but an application re-arms it
 before it is dispatched, we now clear the pending state.
 
 This fixes a bug where an application arms a timer, which fires and is
 marked pending. But before it is dispatched, the application loses
 interest in it and disables it. Now if the timer is re-armed and
 re-enabled later, it will be immediately dispatched as it is still marked
 pending.
 
 This behavior is unexpected, so avoid it by clearing pending state when
 re-arming timers. Note that applications have no way to clear pending
 state themselves, so there's no current workaround.

Same mistake was actually was actually in the handling of changing of
the accuracy and of IO events too. Fixed those too now.

When you push a patch please reply to the mail you posted on
systemd-devel (if you posted one) and simply say Commited. or so, so
that it is easy for us to track what got already merged and what didn't!
Thanks!

 ---
  src/libsystemd-bus/sd-event.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/src/libsystemd-bus/sd-event.c b/src/libsystemd-bus/sd-event.c
 index 0996316..d01e82d 100644
 --- a/src/libsystemd-bus/sd-event.c
 +++ b/src/libsystemd-bus/sd-event.c
 @@ -1241,6 +1241,7 @@ _public_ int sd_event_source_set_time(sd_event_source 
 *s, uint64_t usec) {
  return 0;
  
  s-time.next = usec;
 +source_set_pending(s, false);
  
  if (s-type == SOURCE_REALTIME) {
  prioq_reshuffle(s-event-realtime_earliest, s, 
 s-time.earliest_index);


Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] event: clear pending-state when re-arming timers

2013-11-19 Thread David Herrmann
If a timer fires and is marked pending, but an application re-arms it
before it is dispatched, we now clear the pending state.

This fixes a bug where an application arms a timer, which fires and is
marked pending. But before it is dispatched, the application loses
interest in it and disables it. Now if the timer is re-armed and
re-enabled later, it will be immediately dispatched as it is still marked
pending.

This behavior is unexpected, so avoid it by clearing pending state when
re-arming timers. Note that applications have no way to clear pending
state themselves, so there's no current workaround.
---
 src/libsystemd-bus/sd-event.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/libsystemd-bus/sd-event.c b/src/libsystemd-bus/sd-event.c
index 0996316..d01e82d 100644
--- a/src/libsystemd-bus/sd-event.c
+++ b/src/libsystemd-bus/sd-event.c
@@ -1241,6 +1241,7 @@ _public_ int sd_event_source_set_time(sd_event_source *s, 
uint64_t usec) {
 return 0;
 
 s-time.next = usec;
+source_set_pending(s, false);
 
 if (s-type == SOURCE_REALTIME) {
 prioq_reshuffle(s-event-realtime_earliest, s, 
s-time.earliest_index);
-- 
1.8.4.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel