Skip to content

Commit

Permalink
tst: rawdisk: set debug flags prior to starting the dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
billziss-gh committed Mar 9, 2019
1 parent dbc9065 commit f9b8076
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
26 changes: 14 additions & 12 deletions doc/WinSpd-Tutorial.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,29 @@ The `PipeName` variable has a special purpose. It determines the channel to use
&RawDisk); // <1>
if (0 != Error)
fail(Error, L"error: cannot create RawDisk: error %lu", Error);
SpdStorageUnitSetDebugLog(RawDiskStorageUnit(RawDisk), DebugFlags); // <2>
Error = SpdStorageUnitStartDispatcher(
RawDiskStorageUnit(RawDisk), 2); // <2>
RawDiskStorageUnit(RawDisk), 2); // <3>
if (0 != Error)
fail(Error, L"error: cannot start RawDisk: error %lu", Error);
...
SpdGuardSet(&ConsoleCtrlGuard, RawDiskStorageUnit(RawDisk)); // <3>
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); // <4>
SpdStorageUnitWaitDispatcher(RawDiskStorageUnit(RawDisk)); // <5>
SpdGuardSet(&ConsoleCtrlGuard, 0); // <6>
SpdGuardSet(&ConsoleCtrlGuard, RawDiskStorageUnit(RawDisk)); // <4>
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); // <5>
SpdStorageUnitWaitDispatcher(RawDiskStorageUnit(RawDisk)); // <6>
SpdGuardSet(&ConsoleCtrlGuard, 0); // <7>
RawDiskDelete(RawDisk); // <7>
RawDiskDelete(RawDisk); // <8>
----
<1> Create the rawdisk storage unit.
<2> Start the storage unit dispatcher. At this point the storage unit starts receiving storage requests (if any).
<3> Set a "guarded" pointer to the storage unit so that it can be shutdown in a thread-safe manner by the process console control handler.
<4> Set up a console control handler for the process.
<5> Wait until the storage unit (and its dispatcher) is shutdown.
<6> Reset the "guarded" pointer.
<7> Delete the rawdisk storage unit.
<1> Set debug log flags (-1 to enable all debug logs; 0 to disable all debug logs).
<3> Start the storage unit dispatcher. At this point the storage unit starts receiving storage requests (if any).
<4> Set a "guarded" pointer to the storage unit so that it can be shutdown in a thread-safe manner by the process console control handler.
<5> Set up a console control handler for the process.
<6> Wait until the storage unit (and its dispatcher) is shutdown.
<7> Reset the "guarded" pointer.
<8> Delete the rawdisk storage unit.

We now consider the code for `RawDiskCreate`, `RawDiskDelete` and `ConsoleCtrlHandler`:

Expand Down
3 changes: 1 addition & 2 deletions tst/rawdisk/rawdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,11 @@ int wmain(int argc, wchar_t **argv)
&RawDisk);
if (0 != Error)
fail(Error, L"error: cannot create RawDisk: error %lu", Error);
SpdStorageUnitSetDebugLog(RawDiskStorageUnit(RawDisk), DebugFlags);
Error = SpdStorageUnitStartDispatcher(RawDiskStorageUnit(RawDisk), 2);
if (0 != Error)
fail(Error, L"error: cannot start RawDisk: error %lu", Error);

SpdStorageUnitSetDebugLog(RawDiskStorageUnit(RawDisk), DebugFlags);

info(L"%s -f %s -c %lu -l %lu -i %s -r %s -W %u -C %u -U %u%s%s",
L"" PROGNAME,
RawDiskFile,
Expand Down

0 comments on commit f9b8076

Please sign in to comment.