Quantcast
Channel: VMware Communities : Unanswered Discussions - Virtual Disk Development Kit
Viewing all articles
Browse latest Browse all 872

VidDiskLib crash in Multithread environment

$
0
0

I was going crazy over a crash issue with a module which uses VixDiskLib. The module is a DLL and multiple threads creates an instance of the DLL which does, Init, Connect, Open, Read, write, Close, Disconnect, Exit. The crash is happening when the thread is exiting in the VixDiskLib.dll. After some search I came across the thread

 

http://communities.vmware.com/message/1266395#1266395

 

Which is not similar to the crash I am seeing, but I had violated all the mutithreading rules.

 

  • VixDiskLib_InitEx() or VixDiskLib_Init() should be called only once per process. VMware

recommends that you call them from the main thread.

 

  • In the VixDiskLib_InitEx() or VixDiskLib_Init() call, you can leave the logging callbacks as NULL.

This causes VixDiskLib to provide default logging functions, which are not thread safe. If you are using

VDDK in a multithreaded environment, you should provide your own thread safe logging functions.

 

  • When you call VixDiskLib_Open() and VixDiskLib_Close(), VDDK initializes and uninitializes a

number of libraries. Some of these libraries fail to work if called from multiple threads. For example, the

following call sequence does not work:

 

Thread 1: VixDiskLib_Open ...... VixDiskLib_Close

Thread 2: ................................... VixDiskLib_Open ...... VixDiskLib_Close

 

My application structure is like this - All my VDDK and vStorageAPI implementation is done inside a DLL. VDDK is never exposed to the exe calling the DLL. If a backup of VM has to be done, all the exe has to do is to call a function in the DLL which does the following

 

1. VixDiskLib_init

2. VixDiskLib_Connect

3. VixDiskLib_Open

4. VixDiskLib_Read / VixDiskLib_Write

5. VixDiskLib_Close

6. VixDiskLib_Disconnect

7. VixDiskLib_Exit

 

I was doing this for each thread that is getting called everytime. But according the documentation, I am supposed to call VixDiskLib_Init from the main thread, that may not work for me as it is a DLL. Say if I restrict the simultaneous DLL call to only one - can I call VixDiskLib_Init each time I instantiante the DLL ? Any help is greatly apperitiated !

 

 

Thanks,

./Siva.


Viewing all articles
Browse latest Browse all 872

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>