Modify

Ticket #6323 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

ThreadedFileWriter::Write() writes wrong data if buffer usage < bytes to write

Reported by: anonymous Owned by: ijr
Priority: major Milestone: 0.22
Component: MythTV - General Version: head
Severity: high Keywords:
Cc: stuarta Ticket locked: no

Description

If ThreadedFileWrite::Write() gets called with data larger than the currently free space available in the ring buffer, TFW::Write() loops and writes out the data piece by piece as space gets available. Unfortunately it never bothers increasing the offset for the data buffer it reads from, so it basically writes out the same data every iteration, just different sizes of it.

The following patch fixes that and adds the volatile type modifier to the read and write position variables as they are read from and written to from different threads. This actually tells the compiler about it (which is a good thing) and prevents certain problems from ever happening like we read an old value becomes it still in a register.

Attachments

patch (1.3 KB) - added by Matthias "mortalmatt" Dahl 3 years ago.

Change History

Changed 3 years ago by Matthias "mortalmatt" Dahl

comment:1 Changed 3 years ago by Matthias "mortalmatt" Dahl <devel@…>

Argh, too fast. Certainly the last sentence was more like: "This actually tells the compiler about it (which is a good thing) and prevents certain problems from ever happening like we read an old value because it's still in a cached register."

comment:2 Changed 3 years ago by stuarta

  • Cc stuarta added
  • Version changed from unknown to head
  • Milestone changed from unknown to 0.22

comment:3 Changed 3 years ago by shane

  • Status changed from new to closed
  • Resolution set to fixed

(In [20208]) Closes #6323 Use the correct src buffer offset in TFW.

Thanks to Matthias "mortalmatt" Dahl for the original patch and ijr for the final patch.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.