xbmc / peripheral.joystick

Kodi joystick support (drivers and button maps)
GNU General Public License v2.0
24 stars 46 forks source link

udev: close file descriptor if joystick init is not successful #237

Closed po1vo closed 2 years ago

po1vo commented 2 years ago

I discovered a bug where Kodi keeps opening a joystick device until the number of open file descriptors reaches the kernel limit ("Too many open files").

E.g.:

# lsof -p $(pidof kodi.bin) | grep js0 | wc -l
355

The "joystick" in question:

/dev/input/by-id/usb-MemsArt_MA144_RF_Controller-event-if02 -> ../event8
/dev/input/by-id/usb-MemsArt_MA144_RF_Controller-event-kbd -> ../event5
/dev/input/by-id/usb-MemsArt_MA144_RF_Controller-if01-event-mouse -> ../event6
/dev/input/by-id/usb-MemsArt_MA144_RF_Controller-if01-mouse -> ../mouse1
/dev/input/by-id/usb-MemsArt_MA144_RF_Controller-if03-event-joystick -> ../event9
/dev/input/by-id/usb-MemsArt_MA144_RF_Controller-if03-joystick -> ../js0

I must admit i didn't investigate what part of code kept opening the device, but my patch fixes the problem of leaving FDs open.

po1vo commented 2 years ago

@garbear , thanks. Also please backport this PR to Matrix.

garbear commented 2 years ago

@po1vo will do when I get a chance. my plane leaves for vegas in 4 hours and I haven't slept sooo... might be a while

garbear commented 2 years ago

No joke, that trip took some time to recover from. Spiritually, financially, ethically... Anyways I backported your patch: https://github.com/xbmc/peripheral.joystick/pull/238.

garbear commented 2 years ago

I've tagged a new Nexus version and kicked off some builds. New versions should be available tonight in the repo.