1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-11-22 18:18:26 +02:00

liballegro: fix keyboard readout deadlock triggered in some of the examples

This commit is contained in:
David Kühling 2012-03-29 02:27:36 +02:00
parent e09fbf7a73
commit 2ee0f6e91f
2 changed files with 50 additions and 3 deletions

View File

@ -19,7 +19,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=liballegro PKG_NAME:=liballegro
PKG_VERSION:=4.4.2 PKG_VERSION:=4.4.2
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_SOURCE:=allegro-$(PKG_VERSION).tar.gz PKG_SOURCE:=allegro-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/alleg/allegro/$(PKG_VERSION) PKG_SOURCE_URL:=@SF/alleg/allegro/$(PKG_VERSION)
PKG_BUILD_DIR = $(BUILD_DIR)/allegro-$(PKG_VERSION) PKG_BUILD_DIR = $(BUILD_DIR)/allegro-$(PKG_VERSION)
@ -282,5 +282,5 @@ $(eval $(call BuildPackage,liballegro-utils))
# The following comments configure the Emacs editor. Just ignore them. # The following comments configure the Emacs editor. Just ignore them.
# Local Variables: # Local Variables:
# compile-command: "make -C ~/h/src/qi/openwrt-xburst package/liballegro/compile -j2 V=99" # compile-command: "cd ~/src/nanonote/allegro-4.4.2 && ~/bin/quilt-export target && make -C ~/h/src/qi/openwrt-xburst package/liballegro/compile -j2 V=99"
# End: # End:

View File

@ -1,7 +1,7 @@
Index: allegro-4.4.2/src/linux/lkeybd.c Index: allegro-4.4.2/src/linux/lkeybd.c
=================================================================== ===================================================================
--- allegro-4.4.2.orig/src/linux/lkeybd.c 2011-06-19 11:32:20.000000000 +0200 --- allegro-4.4.2.orig/src/linux/lkeybd.c 2011-06-19 11:32:20.000000000 +0200
+++ allegro-4.4.2/src/linux/lkeybd.c 2011-06-19 11:32:31.000000000 +0200 +++ allegro-4.4.2/src/linux/lkeybd.c 2012-03-29 02:24:07.317094564 +0200
@@ -143,7 +143,10 @@ @@ -143,7 +143,10 @@
/* convert Allegro format scancodes into key_shifts flag bits */ /* convert Allegro format scancodes into key_shifts flag bits */
static unsigned short modifier_table[__allegro_KEY_MAX - __allegro_KEY_MODIFIERS] = static unsigned short modifier_table[__allegro_KEY_MAX - __allegro_KEY_MODIFIERS] =
@ -26,3 +26,50 @@ Index: allegro-4.4.2/src/linux/lkeybd.c
if (key[__allegro_KEY_ALT]) map |= 8; if (key[__allegro_KEY_ALT]) map |= 8;
/* Map scancode to type and value */ /* Map scancode to type and value */
@@ -312,12 +318,25 @@
FD_ZERO(&set);
FD_SET(std_keyboard.fd, &set);
- if (select (FD_SETSIZE, &set, NULL, NULL, &tv) <= 0)
- return 0;
- bytes_read = read(std_keyboard.fd, &buf, sizeof(buf));
- if (bytes_read < 1)
- return 0;
+ /* Possible heisenbug here. when doing readkey(), the main thread does
+ select with timeout and causes us EINTR here. One lost select() an we
+ already hit that "select() is not fully level triggered" lost-wakeup
+ deadlock!? Also note EINTR problem with read() below. */
+
+ while (select (FD_SETSIZE, &set, NULL, NULL, &tv) < 0)
+ {
+ if (errno != EINTR)
+ {
+ return 0;
+ }
+ }
+
+ do {
+ bytes_read = read(std_keyboard.fd, &buf, sizeof(buf));
+ if (bytes_read < 1 && (bytes_read >= 0 || errno != EINTR))
+ return 0;
+ } while (bytes_read < 0);
process_keyboard_data(buf, bytes_read);
Index: allegro-4.4.2/src/keyboard.c
===================================================================
--- allegro-4.4.2.orig/src/keyboard.c 2012-03-29 02:21:50.328523081 +0200
+++ allegro-4.4.2/src/keyboard.c 2012-03-29 02:22:58.768808442 +0200
@@ -625,6 +625,11 @@
_DRIVER_INFO *driver_list;
int i;
+ /* readkey() uses rest(1) which deadlocks unless we call install_timer()
+ first. this bug occurs e.g. with exhello (but not with any of the
+ event-loop driven allegro games) */
+ install_timer();
+
if (keyboard_driver)
return 0;