<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:prahal@yahoo.com" title="Alban Browaeys <prahal@yahoo.com>"> <span class="fn">Alban Browaeys</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - infinite loop when lid events are repeated - list item points to itself"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=103298">bug 103298</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #135132 description</td>
           <td>the version of the patch I applied for session2 - changed to apply against 1.8
           </td>
           <td>the version of the patch I applied for session1 - changed to apply against 1.8
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - infinite loop when lid events are repeated - list item points to itself"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=103298#c13">Comment # 13</a>
              on <a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - infinite loop when lid events are repeated - list item points to itself"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=103298">bug 103298</a>
              from <span class="vcard"><a class="email" href="mailto:prahal@yahoo.com" title="Alban Browaeys <prahal@yahoo.com>"> <span class="fn">Alban Browaeys</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=135132" name="attach_135132" title="the version of the patch I applied for session1 - changed to apply against 1.8">attachment 135132</a> <a href="attachment.cgi?id=135132&action=edit" title="the version of the patch I applied for session1 - changed to apply against 1.8">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=103298&attachment=135132'>[review]</a>
the version of the patch I applied for session1 - changed to apply against 1.8

<span class="quote">>Once the lid is closed, the keyboard event listener is set up to open the lid
>for us on keyboard events. With the right sequence, we can trigger the
>listener to be added to the list multiple times, triggering an assert in the
>list test code (or an infinite loop in the 1.8 branch).</span >
>
<span class="quote">>Conditions:
>* SW_LID value 1 - sets up the keyboard listener
>* keyboard event - sets lid_is_closed to false
>* SW_LID value 0 - is ignored because we're already open
>* SW_LID value 1 - sets up the keyboard listener again</span >
>
<span class="quote">><a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - infinite loop when lid events are repeated - list item points to itself"
   href="show_bug.cgi?id=103298">https://bugs.freedesktop.org/show_bug.cgi?id=103298</a></span >
>
<span class="quote">>Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
>---
> src/evdev-fallback.c | 13 ++++++-------
> test/test-switch.c   | 40 +++++++++++++++++++++-------------------
> 2 files changed, 27 insertions(+), 26 deletions(-)</span >
>
<span class="quote">>--- a/test/test-lid.c
>+++ b/test/test-lid.c
>@@ -426,26 +426,27 @@

>    keyboard = litest_add_device(li, LITEST_KEYBOARD);

>-   litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON);
>-   litest_drain_events(li);
>-
>-   litest_event(keyboard, EV_KEY, KEY_A, 1);
>-   litest_event(keyboard, EV_SYN, SYN_REPORT, 0);
>-   litest_event(keyboard, EV_KEY, KEY_A, 0);
>-   litest_event(keyboard, EV_SYN, SYN_REPORT, 0);
>-   libinput_dispatch(li);
>-
>-   event = libinput_get_event(li);
>-   litest_is_switch_event(event,
>-                          LIBINPUT_SWITCH_LID,
>-                          LIBINPUT_SWITCH_STATE_OFF);
>-
>-   litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY);
>-
>-   litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF);
>-   litest_assert_empty_queue(li);
>-
>-   libinput_event_destroy(event);
>+   for (int i = 0; i < 3; i++) {
>+           litest_lid_action(sw, LIBINPUT_SWITCH_STATE_ON);
>+           litest_drain_events(li);
>+
>+           litest_event(keyboard, EV_KEY, KEY_A, 1);
>+           litest_event(keyboard, EV_SYN, SYN_REPORT, 0);
>+           litest_event(keyboard, EV_KEY, KEY_A, 0);
>+           litest_event(keyboard, EV_SYN, SYN_REPORT, 0);
>+           libinput_dispatch(li);
>+
>+           event = libinput_get_event(li);
>+           litest_is_switch_event(event,
>+                                  LIBINPUT_SWITCH_LID,
>+                                  LIBINPUT_SWITCH_STATE_OFF);
>+           libinput_event_destroy(event);
>+
>+           litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY);
>+
>+           litest_lid_action(sw, LIBINPUT_SWITCH_STATE_OFF);
>+           litest_assert_empty_queue(li);
>+   }
>    litest_delete_device(keyboard);
> }
> END_TEST
>--- a/src/evdev-lid.c
>+++ b/src/evdev-lid.c
>@@ -104,17 +104,16 @@
>    if (!dispatch->keyboard.keyboard)
>            return;

>+   libinput_device_remove_event_listener(&dispatch->keyboard.listener);
>+
>    if (is_closed) {
>            libinput_device_add_event_listener(
>                                    &dispatch->keyboard.keyboard->base,
>                                    &dispatch->keyboard.listener,
>                                    lid_switch_keyboard_event,
>                                    dispatch);
>-   } else {
>-           libinput_device_remove_event_listener(
>-                                   &dispatch->keyboard.listener);
>-           libinput_device_init_event_listener(
>-                                   &dispatch->keyboard.listener);
>+
>+           libinput_device_init_event_listener(&dispatch->keyboard.listener);
>    }
> }

>@@ -130,11 +129,12 @@
>    case SW_LID:
>            is_closed = !!e->value;

>-           if (dispatch->lid_is_closed == is_closed)
>-                   return;
>            lid_switch_toggle_keyboard_listener(dispatch,
>                                                is_closed);

>+           if (dispatch->lid_is_closed == is_closed)
>+                   return;
>+
>            dispatch->lid_is_closed = is_closed;

>            lid_switch_notify_toggle(dispatch, device, time);</span ></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>