#1168 closed bug (fixed)
driver free hook not called
Reported by: | marcusoverhagen | Owned by: | marcusoverhagen |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | System/Kernel | Version: | R1/pre-alpha1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
When an application has opened a driver and doesn't close it, the driver's free hook will not be called when the application crashes or is killed. However, the close hook does get called.
It looks like vfs_free_io_context() calls close_fd() and put_fd(), close_fd will call close hook if previous reference count was 1 put_fd will call free hook if previous reference count was 1. Something is wrong with that logic
example:
ls /dev/dvb/cs23882/1 cx23882: driver open cx23882: driver read cx23882: driver close cx23882: driver free . tail -f /dev/dvb/cs23882/1 (or opening media server and killing media_server) cx23882: driver open cx23882: driver read cx23882: driver close . ls /dev/dvb/cs23882/1 cx23882: driver open (=> B_BUSY, because free hook wasn't called)
Change History (10)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
I can't reproduce your problem at all. First of all, "ls" never opens the driver here, neither does media_server open the driver (possibly because of the missing add-on :-)). But also, "tail -f" nicely ends in close/free as expected. Are you building with GCC 2.95.3? Or can you provide any more info? If not, I'm afraid you'll have to look into this yourself.
comment:3 by , 18 years ago
The driver doesn't work for you because you don't have the hardware, and init_hardware returns an error.
The add-on is done, but I can't checkin anything because berlios is down.
I wrote a stripped down test driver, but it works as it's supposed to :(
The problem occured on 2.95.3-beos-060710 (but not with the test driver).
I'll continue investigating this. It's still reproduceable with the cx23882 driver, and I think the same happens with auich driver, which prevents it from working again when media server is restarted.
comment:4 by , 18 years ago
I changed the driver to accept any hardware, but it still worked as supposed to; I tried with /dev/dprintf before which also worked. I think the auich driver works on my laptop, I'll try to reproduce the problem there tomorrow.
comment:5 by , 18 years ago
Status: | new → assigned |
---|
I can reproduce the bug with the auich driver, thanks for the hint! I'll look into it.
comment:6 by , 18 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
Sorry, I made a mistake with copy&paste of the debug output: I can't reproduce this problem at all.
comment:7 by , 18 years ago
testcase added in hrev20801. The driver does freeze inside the close hook, when snooze(200000) is called.
comment:8 by , 18 years ago
I forgot to add that this freeze happens when the application using the driver is killed.
To reproduce:
/bin/echo 12345678901234567890 >/dev/misc/test/1 and press ctrl+c after about 1 second
You missed that put_fd() checks ref_count while close_fd() checks open_count - but other than that, I'll look into it :-)