Opened 16 years ago
Closed 16 years ago
#5591 closed patch (fixed)
Fix ThreadedFileWriter potential deadlock
Reported by: | Owned by: | Isaac Richards | |
---|---|---|---|
Priority: | major | Milestone: | unknown |
Component: | mythtv | Version: | unknown |
Severity: | medium | Keywords: | ThreadedFileWriter deadlock |
Cc: | Ticket locked: | no |
Description
If ThreadedFileWriter::Write() is fed more data than can fit into it's internal buffer, it will deadlock. ThreadedFileWriter::Write() will block waiting for BufFree?() to be greater than the data to be written, but that will never happen.
The attached patch creates a loop in ThreadedFileWriter::Write() to process the fed data into the internal buffer as space becomes available. This can cause ThreadedFileWriter::Write() to take longer to return, but as long as the recorder has a big enough buffer (or uses DeviceReadBuffer?), then it should not be a problem.
The other option is for ThreadedFileWriter::Write() to only process as much as it can in one pass, then return that amount to the calling function. However, this causes a problem with keyframes. Since "recorders" need to note the position in the file where keyrframes are written, if they don't actually get written, then the position would be wrong.
I found this problem with recording from the HD-PVR. I was experiencing deadlocks in about 1:10 recordings.
Attachments (3)
Change History (6)
Changed 16 years ago by
Attachment: | ThreadedFileWriter-deadlock.patch added |
---|
Changed 16 years ago by
Attachment: | ThreadedFileWriter-deadlock-v1.1.patch added |
---|
Re-order some statements for efficiency.
comment:1 Changed 16 years ago by
The original patch could execute the loop with no data, causing a mutex wait when no data was ready to be processed.
New patch added which fixes that.
comment:2 Changed 16 years ago by
comment:3 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [18105]) Fixes #5591. Fixes a deadlock on very large writes to the ThreadedFileWriter?.
Fix deadlock in ThreadedFileWriter::Write()