Video Screencast Help

Simulating Locked Files For Application Robustness!

Created: 15 Nov 2013
ianatkin's picture
+1 1 Vote
Login to vote

Today I've been troubled by a pesky random issue with our ImageInvoker. Sometimes, we have network problems which throw the ImageInvoker service into a fit.

ImageInvoker works by exchanging files across a file share as communication 'envelopes'. The client saves a .ini file to the express share to ask the server a question, and the server saves an .rsp file which is the reply that the client reads.

The problem seems to be that sometimes the .ini file isn't accessable at the moment ImageInvoker process attempts to read it. So I ammended the code to combat this, but then wondered how to simulate this rare problem.

My first approach was to use the following vbscript to open the file and lock it for editing. This is what I thought would most closely resemble an open file handle from a slow write on a contended network,

 

 

Dim fs0,ts
Dim myfile
Set fso = CreateObject("Scripting.FileSystemObject")
 
Myfile="C:\Program Files\Altiris\eXpress\Deployment Server\Temp\ImageInvoker_In\000c291f60bf.ini"
 
Const OpenFileForWriting = 2
Const OpenFileForAppending = 8
Set ts = fso.OpenTextFile(myfile, OpenFileForAppending,True)
msgbox "Locked"
 
ts.close
 
This however didn't replicate the problem in the existing ImageInvoker code; it could read the file fine, it just couldn't clean it up afterwards.
 
So I thought about how else I can lock the file so it couldn't even be read. The only way I came up with was to cheat and use permissions; I just edited the indiviual files permissions and set the advanced permissions configuration to "deny" for everyone. That stopped the file from being read by ImageInvoker which then simulated the issue in the existing code nicely.
 
Ammended code now ready for a production firing....

Now, if only we could actually image across that network.... ;-)