Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#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:
Has a Patch: no 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 Changed 12 years ago by axeld

You missed that put_fd() checks ref_count while close_fd() checks open_count - but other than that, I'll look into it :-)

comment:2 Changed 12 years ago by axeld

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 Changed 12 years ago by marcusoverhagen

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 Changed 12 years ago by axeld

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 Changed 12 years ago by axeld

Status: newassigned

I can reproduce the bug with the auich driver, thanks for the hint! I'll look into it.

comment:6 Changed 12 years ago by axeld

Owner: changed from axeld to marcusoverhagen
Status: assignednew

Sorry, I made a mistake with copy&paste of the debug output: I can't reproduce this problem at all.

comment:7 Changed 12 years ago by marcusoverhagen

testcase added in hrev20801. The driver does freeze inside the close hook, when snooze(200000) is called.

comment:8 Changed 12 years ago by marcusoverhagen

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

comment:9 Changed 12 years ago by axeld

Resolution: fixed
Status: newclosed

Fixed in hrev20808.

comment:10 Changed 12 years ago by marcusoverhagen

Confirmed, the problem with DVB driver is gone. Thanks.

Note: See TracTickets for help on using tickets.