Driver: Fix clearing on device close.

This commit is contained in:
Nodir Temirkhodjaev 2018-02-21 16:02:37 +05:00
parent b22da96799
commit 02ea6870b5
3 changed files with 29 additions and 8 deletions

View File

@ -103,6 +103,16 @@ fort_buffer_close (PFORT_BUFFER buf)
fort_buffer_data_del(buf->data_free);
}
static void
fort_buffer_clear (PFORT_BUFFER buf)
{
fort_buffer_close(buf);
buf->data_head = NULL;
buf->data_tail = NULL;
buf->data_free = NULL;
}
static NTSTATUS
fort_buffer_prepare (PFORT_BUFFER buf, UINT32 len, PCHAR *out,
PIRP *irp, ULONG_PTR *info)

View File

@ -660,6 +660,12 @@ fort_callout_remove (void)
}
}
static void
fort_callout_defer_flush (BOOL dispatchLevel)
{
fort_defer_flush(&g_device->defer, fort_transport_inject_complete, dispatchLevel);
}
static NTSTATUS
fort_callout_force_reauth (PDEVICE_OBJECT device,
const FORT_CONF_FLAGS old_conf_flags,
@ -672,7 +678,15 @@ fort_callout_force_reauth (PDEVICE_OBJECT device,
UNUSED(device);
fort_stat_update(stat, conf_flags.log_stat);
fort_timer_update(&g_device->timer, FALSE);
if (old_conf_flags.log_stat != conf_flags.log_stat) {
fort_stat_update(stat, conf_flags.log_stat);
if (!conf_flags.log_stat) {
fort_callout_defer_flush(FALSE);
}
}
if ((status = fort_prov_open(&engine)))
goto end;
@ -728,12 +742,6 @@ fort_callout_force_reauth (PDEVICE_OBJECT device,
return status;
}
static void
fort_callout_defer_flush (BOOL dispatchLevel)
{
fort_defer_flush(&g_device->defer, fort_transport_inject_complete, dispatchLevel);
}
static void
fort_callout_timer (void)
{
@ -834,6 +842,9 @@ fort_device_cleanup (PDEVICE_OBJECT device, PIRP irp)
fort_callout_force_reauth(device, old_conf_flags, conf_flags);
}
/* Clear buffer */
fort_buffer_clear(&g_device->buffer);
/* Device closed */
{
KLOCK_QUEUE_HANDLE lock_queue;

View File

@ -427,7 +427,7 @@ fort_stat_update (PFORT_STAT stat, BOOL log_stat)
KeAcquireInStackQueuedSpinLock(&stat->lock, &lock_queue);
if (stat->log_stat) {
if (stat->log_stat && !log_stat) {
tommy_hashdyn_foreach_node(&stat->flows_map, fort_stat_flow_close);
fort_stat_init(stat);