feat(dlp): graceful shutdown and COM cleanup for email collector
This commit is contained in:
@@ -610,6 +610,7 @@ if ($useOutlook) {
|
||||
# Main loop
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
while ($true) {
|
||||
try {
|
||||
Flush-Wal
|
||||
@@ -652,3 +653,22 @@ while ($true) {
|
||||
|
||||
Start-Sleep -Seconds $resolvedPollSeconds
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Write-CollectorHealth -Status 'stopped'
|
||||
try {
|
||||
if ($null -ne $script:SentFolder) {
|
||||
[void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($script:SentFolder)
|
||||
$script:SentFolder = $null
|
||||
}
|
||||
if ($null -ne $script:OutlookNamespace) {
|
||||
[void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($script:OutlookNamespace)
|
||||
$script:OutlookNamespace = $null
|
||||
}
|
||||
if ($null -ne $script:OutlookApp) {
|
||||
[void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($script:OutlookApp)
|
||||
$script:OutlookApp = $null
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user