On 02-Dec-2002 Johannes Erdfelt wrote:
> On Mon, Dec 02, 2002, Duncan Haldane <[EMAIL PROTECTED]>
> wrote:
>> If you have a USB webcam please let me know what happens if you 
>> disconnect its usb cable while it is streaming images to a v4l viewer
>>  (mine hangs)
> Sounds like a bug. I'll take the blame since I originally wrote the code
>:)
> 
>> The same thing happens when I yank the usb cable of a running ov511
>> cam, so its not just a cpia issue....
>> (I only have cpia and ov511 cams to test with).
> 
> Could be because ov511 was based on the original cpia code so it has the
> same bug?


AARGH!!! Yes!! After much wailing and gnashing of teeth I found why cpia
and ov511 drivers hang when the usb cable is yanked out while the camera
is open....

In both cases, in this special case, the unregister_video_device() call is
postponed to be the penultimate act of the [cpia,ov51x_v4l1]_close()  call....

BUT....
    
cpia_close is itself called by videodev.c:video_release() when the v4l app is
closed..., as follows:

down(videodev_lock);
vfl->close(vfl);
up(videodev_lock);

unfortunately, vfl->close is a pointer to cpia_close(),
which if it calls unregister_video_device(), hangs because
that also starts out with a
down(videodev_lock); ......

Moral: You can't postpone unregistering the video device
until the *_close() call.

Hmmm.
That was painful to find!
I hope no other v4l drivers do this...

I'm fixing the cpia driver using the "postponed kfree" 
disconnect method used by the pwc driver, that allows an earlier 
unregister call.

Duncan






--
video4linux-list mailing list
Unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/video4linux-list

Reply via email to