Interaction between application and SDK on Unix-like platforms

Interaction between the SDK and your application can be implemented in two ways.

In-process mode

Commonly, your application and the SDK are both running on one computer. The program modules of KAV SDK run within the address space of your application. In this case, the KAV scanning server runs as a child process for the parent process, which is your application, and does that in the same address space.

Interaction between your application and KAV SDK scanning server goes in the following manner. The application passes file names and specifies other objects for the scanning engine (KAV Engine); the engine opens and scans them in-place. There can be one or more scanning (or monitoring) threads. No separate process is created for the KAV scanning server. The KAV scanning server provides programming interfaces and their methods for your application behaving as a client for the KAV server. The described mode is called in-process interaction. There can be three or more scanning processes.

In-process interaction in Linux

SDK operating from within the application

Out-of-process and service mode

The second way of interaction between your client application and KAV SDK scanning server is typically useful when your application and the scanning server run on different computers. In this case your client application and KAV scanning server run isolated as two separate processes and do not share a common address space.

This way is based on the following two underlying client-server interaction modes: the out-of-process mode and service mode.

In the out-of-process mode the process implementing KAV SDK server’s functionality runs as a separate process, which is associated with an ELF executable binary (the kavescanner residing in the ./ppl directory within the KAV SDK program directory) on a remote computer. There is nothing that can stop you from running the server executable on the same local computer as your application for the sake of address space isolation. Additionally, there is also the kavehost ELF binary (residing in the ./bin directory) that serves as a arbiter for the kavescanner processes that perform the scanning tasks received from your application.

In the service mode a yet one entity appears—the kavehost script (located in the ./etc/init.d directory). The kavehost in this case is a service that, when a scanning request is received from your application, does the following. It reads its configuration file to checking to see how many scanning kavescanner processes should be started for simultaneous scanning, and instantiates kavescanner.

There is one process from which three or more scanning processes fork.

Operating as separate process in Linux

SDKs operating as separate processes

As soon as the SDK is initialized, a new process pool is created. The main kavehost ELF executable starts the main kavescanner process that forks a tree of several (typically three) working kavescanner scanning child processes. These working processes are created solely for processing scanning tasks, when the scanning tasks are created and manged by the main parent kavescanner process. The parent kavescanner process retrieves requests from your application via the kavehost process, which handles them by creating scanning tasks and assigning your requests to specific tasks, and arbitrates the tasks between the working processes it created. This kavehost process is then called arbiter, where the kavescanner process is the scanner server and hosts the KAV Engine and malware definition database files used by the scanning engine. Such approach provides for easy implementation of multiprocessing architecture.

Please always make sure the kavescanner resides in the ./ppl directory within the program directory with KAV SDK modules, or else set the LD_LIBRARY_PATH and KL_PLUGIN_PATH system variables to specify the path to KAV Engine’s modules and the kavscanner ELF executable.

Some temporary files are created in the working directory of kavehost service, including sdk8l3_env_registry.xml and sdk8l3_registry.xml files used to virtualize Windows registry on Linux platform.

Each working process can handle a single scanning task at once. If your application passes more then three files to scan, the arbiter spawns yet more processes, one for each of the generated scanning tasks up until the limit for the maximum number of spawned scanning processes is reached.

The limit specifying the maximum number of scanning processes that can be spawned by the arbiter, is specified by the MaxScannersCount option of the kavehost.xml configuration file. For more information about the configuration file, see section "Kavehost service configuration file".

When one of the scanning processes finishes processing assigned scanning task, it terminates, returning results to the arbiter that hands them over to your application. After the request processing is completed, the corresponding process is terminated, but only if there are yet more than three active scanning processes. The SDK always keeps a minimum of three started scanning processes to serve a least three scanning tasks at once. Starting and closing the excess scanning processes is managed by arbiter.

The maximum allowed number of simultaneously running scanning processes can also be defined at the SDK initialization stage in the dwOutprocScannersCount input parameter of the kaveInitializeEx function.

Described approach provides for a platform independent architecture with simultaneous processing of tasks delivered from your application.

HTTP service mode

In HTTP service mode, KAV SDK operates similar to service mode. Your application makes HTTP requests to an HTTP service called KAV HTTPD, and this service scans files passed in these requests and then returns the response with the results. For more information about HTTP service mode, see section "Using KAV SDK in HTTP mode".

Page top