clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
215 stars 72 forks source link

client api datastore locking #293

Closed jaeho9929 closed 2 years ago

jaeho9929 commented 2 years ago

I tried to connect to clixon_backend using client api, but, clixon_handle variable always returns null except the backend in the initial state. So, I found a snippet, in clixon_client.c. Is this intended?

olofhagsand commented 2 years ago

I think those two things are unrelated. Yes, the snippet looks fishy, I will take a look at it, but it is unlock in a client disconnect, the backend normally breaks the lock on session close anyway. I am a little curious on what you mean with "clixon_handle variable always returns null " more concretely? Do you refer ato a variable/function call and in which context?

jaeho9929 commented 2 years ago

Sorry, it was clixon_client_handle not clixon_handle. I tested with a little modified version of code in reference in doc.

// binary name : my_client_api
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>

#include <clixon/clixon_client.h>

int main(int argc, char **argv)
{
    clixon_handle h = NULL;
    clixon_client_handle ch = NULL;

    uint32_t n = 0;

    if ((h = clixon_client_init("/usr/local/etc/example.xml")) == NULL)
        return -1;

    // ch return always null except first attempt
    if ((ch = clixon_client_connect(h, CLIXON_CLIENT_NETCONF)) == NULL)
        return -1;

    clixon_client_disconnect(ch);
    clixon_client_terminate(h);

    return 0;
}
# shell command
./clixon_backend -F /usr/local/etc/example.xml -s init -D 2
./my_client_api --> return with 0
./my_client_api --> return with -1
krihal commented 2 years ago

Hi,

I tried to reproduce this using your example and the Clixon code from GitHub, but I don't get the same results as you do:

# cc -o test test.c  -lclixon
# ./test; echo $?
0
# ./test; echo $?
0
# ./test; echo $?
0

What version of Clixon are you using? And have you made any other modifications?

jaeho9929 commented 2 years ago

Sorry, this was my mistake. I think this was my environmental problem. In a clean environment in VM, and tried to reproduce it (1808015). And, It was no problem.