Why cdb_close close any socket which is opened by app. ideally it should close those sockets which are connected to confd using cdb_connect?

Why cdb_close close any socket which is opened by app. ideally it should close those sockets which are connected to confd using cdb_connect ?

Since you have access to the libconfd source code, you can take a look at what the cdb_close() API call will do yourself:

$ cat libconfd/src/cdb.c | grep -A 10 cdb_close
int cdb_close(int sock)
{
    if (close(sock) != 0) {
        return ret_err(CONFD_ERR_OS, "Failed to close socket: %s",
                       strerror(errno));
    }
    return CONFD_OK;
}