confD Multi-threading

Hi All,

In confD Application I am running the following sockets in a single process and I am planning to enable multi-threading.

socket used:
CDB : Data, Subscription Socket:
Control socket and 3 Worker socket – Action, Operational Data and Notification.

  1. Let me know if I can go ahead with adding a separate thread for each of these control/worker sockets? (this will be mostly a single user system).
    Anything else that I have to keep in mind, like if there is some API that might cause problems and needs special attention, when used in multi-threading environment.

  2. In 26.2 Advanced Topics -> Locks, I saw the info on the various locks being used within confd.
    I like to know if I might need any external locks (mutex) in multi-threading environment (or) in any specific scenario? (assuming that, I don’t have any external data that is being accessed by multiple sockets, and there is one thread per each socket)

    I have taken a look at 9-c-threads examples, and I don’t see any external locks being used.

Thanks
Kapil.

Yes, you can have a main thread owning the control socket and a set of worker threads, each owning its own worker socket. There is an excellent discussion on the multi-threading topic in Chapter 6.7 of the ConfD User called “The Protocol and a Library Threads Discussion”. In addition to the 9-c_threads example, there is also a very good discussion in Chapter 11.2.2 of the ConfD User Guide called “Using Threads”.

It is important to note that threads cannot share socket connections to ConfD as it may cause unpredictable results.

The locks as discussed in the Advanced Topics chapter of the User Guide are for controlling access to the datastores such as running, startup, and candidate. They are not necessarily needed for the use of multi-threading to handle the different control and worker sockets.

Thanks for the clarification @waitai

Will it be advisable to use multi-threading on CDB Data/Subscription sockets? like any possible scenarios that can make use of CDB sockets with multi-threading ?

From what i see from User guide, multi-threading is advised only for control/worker sockets.

-kapil

It is important to note that some CDB API calls are blocking and require forking a process or spawning a thread. They include cdb_trigger_subscriptions( ), and cdb_replay_subscriptions( ).