>Betreff : Re: [linux-minidisc] another way to send SCSI commands >Gesendet: 04.12.2010 18:23:41 >An : "Thomas Arp <manner.moe@gmx.de>" >Von: "Michael Karcher <Michael.Karcher@fu-berlin.de>" >----- Originale Nachricht ----- >Am Samstag, den 04.12.2010, 14:33 +0100 schrieb Thomas Arp: >> I´m rewriting himdscsitest.c using the dvd-rw-tools headers for >> testing. >That's great! O.K., here is the new source code. >> As far as i have tested yet when cmd.transport() has finished the >> Scsi_Command structure will be closed automatically. >As far as I can see, this is neither the case for Windows nor for Linux. >Can you point out the code you think it closes the file descriptor? I >see closing only in the destructor of Scsi_Command, so the device is >closed only when the Scsi_Command structure goes out of scope. >But I *do* see a potential problem that causes early closes: The >Scsi_Command structure must never be copied, as it violates the C++ >"rule of three": > http://en.wikipedia.org/wiki/Rule_of_three_%28C%2B%2B_programming%29 >"must never be copied" is *not* talking about DRM here (SCNR), but means >that you can not pass a "Scsi_Command" as value to a subfunction, >because pass-by-value copies the data (and that includes the handle) to >local storage of the subfunction, and if that subfunction terminates, >the local copy is destructed, closing the handle, although the object it >was copied from in the caller still is alive. Also hell will break loose >(i.e. you will get early closed fds/double-closed fds/leaked fds) if you >assign one Scsi_Command object to another one. So do only pass the >Scsi_Command structure by reference or pointer! Yes, this was exactly my problem. Thomas
Attachment:
himdscsitest_dvd-tools.cpp
Description: Binary data