是否可以合理地解决防病毒扫描工作目录? [英] Is it possible to reasonably workaround an antivirus scanning the working directory?

查看:133
本文介绍了是否可以合理地解决防病毒扫描工作目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Win32应用程序在运行时在指定的临时文件夹中执行大量磁盘操作,并且认真重新设计它不是问题。

My Win32 application performs numerous disk operations in a designated temporary folder while functioning, and seriously redesigning it is out of the question.

某些客户端具有扫描的防病毒软件相同的临时目录(它只是扫描一切)。我们试图将它们说成禁用它 - 它不起作用,所以这也是不成问题的。

Some clients have antivirus software that scans the same temporary directory (it simply scans everything). We tried to talk them into disabling it - it doesn't work, so it's out of the question either.

每隔一段时间(每一次就像一次我的应用程序尝试对由防病毒打开的文件执行操作,因此被操作系统锁定。发生共享冲突,并在我的应用程序中导致错误。平均在三分钟内发生这种情况。

Every once in a while (something like once for every one thousand file operations) my application tries to perform an operation on a file which is at that very time opened by the antivirus and is therefore locked by the operating system. A sharing violation occurs and causes an error in my application. This happens about once in three minutes on average.

在大多数典型情况下,临时文件夹最多可包含100k个文件,所以我不喜欢让他们在任何时候都打开,因为这可能会导致在某些边缘条件下的资源不足。

The temporary folder can contain up to 100k files in most typical scenarios, so I don't like the idea of having them open at all times because this could cause running out of resources on some edge conditions.

我的应用程序是否有一些合理的策略来对需要的文件锁定的情况做出反应?可能是这样的?

Is there some reasonable strategy for my application to react to situations when a needed file is locked? Maybe something like this?

for( int i = 0; i < ReasonableNumber; i++ ) {
    try {
        performOperation(); // do useful stuff here
        break;
    } catch( ... ) {
        if( i == ReasonableNumber - 1 ) {
            throw; //not to hide errors if unlock never happens
        }
    }
    Sleep( ReasonableInterval );
 }

这是一个可行的策略吗?如果是这样,应该重试多少次,多久?有什么更好的想法?

Is this a viable strategy? If so, how many times and how often should my application retry? What are better ideas if any?

推荐答案

我已经有赛门铁克和AVG制作的防病毒软件的经验,导致文件无法开放。

I've had experience with antivirus software made by both Symantec and AVG which resulted in files being unavailable for open.

我们在2002年的赛季中遇到的一个常见问题是与MSDev6文件按照以下顺序更新:

A common problem we experienced back in the 2002 time frame with Symantec was with MSDev6 when a file was updated in this sequence:


  1. 打开文件

  2. 内容在内存中修改

  3. 应用程序需要提交更改

  4. 应用程序创建新的tmp文件,新的文件副本+更改

  5. 应用程序删除旧文件

  6. 应用程序副本tmp文件到旧文件名

  7. 应用程序删除tmp文件

  1. a file is opened
  2. contents are modified in memory
  3. application needs to commit changes
  4. application creates new tmp file with new copy of file + changes
  5. application deletes old file
  6. application copies tmp file to old file name
  7. application deletes the tmp file

问题出现在步骤5和步骤6.赛门铁克将做一些减缓删除的事情,阻止创建具有相同名称的文件(CreateFile返回ERROR_DELETE_PENDING)。 MSDev6将无法注意到 - 意味着步骤6失败。步骤7仍然发生。原来的删除将最终完成。因此,文件不再存在于磁盘上!

The problem would occur between step 5 and step 6. Symantec would do something to slowdown the delete preventing the creation of a file with the same name (CreateFile returned ERROR_DELETE_PENDING). MSDev6 would fail to notice that - meaning step 6 failed. Step 7 still happened though. The delete of the original would eventually finish. So the file no longer existed on disk!

使用AVG,我们遇到间歇性问题,能够打开刚刚修改的文件。

With AVG, we've been experiencing intermittent problems being able to open files that have just been modified.

我们的解决方案是一个合理的循环中的尝试/捕获。我们的循环数为5。

Our resolution was a try/catch in a reasonable loop as in the question. Our loop count is 5.

这篇关于是否可以合理地解决防病毒扫描工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆