ps2_drv: handle event-queue overflow

Fixes #1185
This commit is contained in:
Norman Feske 2014-06-26 11:55:02 +02:00
parent b6f8bcca6a
commit 365925a9ad
2 changed files with 20 additions and 0 deletions

View File

@ -444,6 +444,11 @@ class Ps2_keyboard : public Input_driver
PLOG("post %s, key_code = %d\n", PLOG("post %s, key_code = %d\n",
press ? "PRESS" : "RELEASE", key_code); press ? "PRESS" : "RELEASE", key_code);
if (_ev_queue.avail_capacity() == 0) {
PWRN("event queue overflow - dropping events");
_ev_queue.reset();
}
/* post event to event queue */ /* post event to event queue */
_ev_queue.add(Input::Event(press ? Input::Event::PRESS _ev_queue.add(Input::Event(press ? Input::Event::PRESS
: Input::Event::RELEASE, : Input::Event::RELEASE,

View File

@ -82,6 +82,15 @@ class Ps2_mouse : public Input_driver
int _packet_len; int _packet_len;
int _packet_idx; int _packet_idx;
void _check_for_event_queue_overflow()
{
if (_ev_queue.avail_capacity())
return;
PWRN("event queue overflow - dropping events");
_ev_queue.reset();
}
/** /**
* Generate mouse button event on state changes * Generate mouse button event on state changes
* *
@ -97,6 +106,8 @@ class Ps2_mouse : public Input_driver
if (verbose) if (verbose)
Genode::printf("post %s, key_code = %d\n", new_state ? "PRESS" : "RELEASE", key_code); Genode::printf("post %s, key_code = %d\n", new_state ? "PRESS" : "RELEASE", key_code);
_check_for_event_queue_overflow();
_ev_queue.add(Input::Event(new_state ? Input::Event::PRESS _ev_queue.add(Input::Event(new_state ? Input::Event::PRESS
: Input::Event::RELEASE, : Input::Event::RELEASE,
key_code, 0, 0, 0, 0)); key_code, 0, 0, 0, 0));
@ -223,6 +234,8 @@ class Ps2_mouse : public Input_driver
if (verbose) if (verbose)
Genode::printf("post MOTION, rel_x = %d, rel_y = %d\n", rel_x, rel_y); Genode::printf("post MOTION, rel_x = %d, rel_y = %d\n", rel_x, rel_y);
_check_for_event_queue_overflow();
_ev_queue.add(Input::Event(Input::Event::MOTION, _ev_queue.add(Input::Event(Input::Event::MOTION,
0, 0, 0, rel_x, rel_y)); 0, 0, 0, rel_x, rel_y));
} }
@ -243,6 +256,8 @@ class Ps2_mouse : public Input_driver
if (verbose) if (verbose)
Genode::printf("post WHEEL, rel_z = %d\n", rel_z); Genode::printf("post WHEEL, rel_z = %d\n", rel_z);
_check_for_event_queue_overflow();
_ev_queue.add(Input::Event(Input::Event::WHEEL, _ev_queue.add(Input::Event(Input::Event::WHEEL,
0, 0, 0, 0, rel_z)); 0, 0, 0, 0, rel_z));
} }