To make sure that multithreaded filter processes are thread-safe, you must create a unique context pointer for every thread by calling fpInit()
. In addition, threads must not share context pointers, and the same context pointer must be used for all API calls in the same thread. This applies to in-process and out-of-process API calls. Creating a context pointer for every thread does not affect performance because the context pointer uses minimal resources.
For example, C code for file filtering must have the following logic in a thread:
fpInit() KVGetExtractInterface() fpOpenFile() fpGetMainFileInfo() /* container file */ fpGetSubFileInfo() fpExtractSubFile fpGetSubFileMetadata() fpFilterFile() fpCloseFile() fpOpenFile() fpGetMainFileInfo() /* not a container file */ fpGetDocInfoFile() fpGetOLESummaryInfoFile() fpFilterFile() fpCloseFile() ... fpShutdown()
|