UsbDk: Add OnClose callback to Strategies
OnClose is called when device symlink is fully closed by used mode. For redirector strategy OnClose stops redirection. For other strategies OnClose is currently no-op. Signed-off-by: Pavel Gurvich <pavel@daynix.com> Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit is contained in:
parent
2514bdc4ea
commit
093251727e
3 changed files with 18 additions and 0 deletions
|
|
@ -59,6 +59,9 @@ public:
|
|||
|
||||
CUsbDkControlDevice* GetControlDevice()
|
||||
{ return m_ControlDevice; }
|
||||
|
||||
virtual void OnClose(){}
|
||||
|
||||
protected:
|
||||
CUsbDkFilterDevice *m_Owner = nullptr;
|
||||
CUsbDkControlDevice *m_ControlDevice = nullptr;
|
||||
|
|
|
|||
|
|
@ -584,6 +584,19 @@ size_t CUsbDkRedirectorStrategy::GetRequestContextSize()
|
|||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
void CUsbDkRedirectorStrategy::OnClose()
|
||||
{
|
||||
USB_DK_DEVICE_ID ID;
|
||||
UsbDkFillIDStruct(&ID, *m_DeviceID->begin(), *m_InstanceID->begin());
|
||||
|
||||
auto status = m_ControlDevice->RemoveRedirect(ID);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_REDIRECTOR, "%!FUNC! RemoveRedirect failed: %!STATUS!", status);
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
void CUsbDkRedirectorQueueData::SetCallbacks(WDF_IO_QUEUE_CONFIG &QueueConfig)
|
||||
{
|
||||
QueueConfig.EvtIoWrite = [](WDFQUEUE Q, WDFREQUEST R, size_t L)
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ public:
|
|||
virtual void WritePipe(WDFREQUEST Request, size_t Length) override;
|
||||
virtual void ReadPipe(WDFREQUEST Request, size_t Length) override;
|
||||
|
||||
virtual void OnClose() override;
|
||||
|
||||
void SetDeviceID(CRegText *DevID)
|
||||
{ m_DeviceID = DevID; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue