# Facing issues in implementing get\_next call

**URL:** <https://dmap-community.ductus.global/t/facing-issues-in-implementing-get-next-call/866>\
**Category:** CDB and CDB API\
**Created:** [December 1, 2016, 10:20am UTC](https://dmap-community.ductus.global/t/facing-issues-in-implementing-get-next-call/866 "2016-12-01T10:20:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vipbansa](https://avatars.discourse-cdn.com/v4/letter/v/a88e4f/32.png) [@vipbansa](https://dmap-community.ductus.global/u/vipbansa)\
**Post date:** [December 1, 2016, 10:20am UTC](https://dmap-community.ductus.global/t/facing-issues-in-implementing-get-next-call/866/1 "2016-12-01T10:20:03Z")

</div>

Hi,

I am implementing get\_next api callback for folloiwing yang model.

Yang :-

```auto
container policy {
    config false;
    list ks_policy {
        key addr;
        leaf addr {
            type inet:ip-address;
        }
        leaf port {
            type uint8;
        }
    }
}

```

As mentioned in the Yang the `ks_policy` is a list with addr as the key.

In the get\_next function i am getting next= -1 for first time then i am adding

```
CONFD_SET_IPV4(&v, in);
confd_data_reply_next_key(tctx, &v, 1, (long)element->next);

```

In my implementation element-\>next is NULL so the next time when the get\_next is called the variable next should have the value 0 but it is getting called with next as -1 again.

but third time get\_next is not getting called. Its getting called for 2 times with next = -1 both the times.

Is there anything i am missing?

Thanks,  
Vipin Bansal

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [December 1, 2016, 2:07pm UTC](https://dmap-community.ductus.global/t/facing-issues-in-implementing-get-next-call/866/2 "2016-12-01T14:07:04Z")

</div>

Hello,

ConfD internally can use get\_next() callback not only to get first element, but for other purposes too, e.g. to verify that “some” records exist in the list…

This is the reason why you see get\_next(-1) twice, not only once.

Due to how data provider API is defined - and independence of data provider callbacks, this should not cause any problems to your implementation…

Consider any get\_next(-1) call as a standalone request - it should not be important what happened before, of what happens after…

Why the callback is not invoked for 3rd time I cannot say without more information - did your callback respond for the “2nd” invocation same way like for the first? Did any of sub-seqent callbacks run with error? (e.g. some get\_elem())…

---

<div class="post-metadata">

**Author:** ![vipbansa](https://avatars.discourse-cdn.com/v4/letter/v/a88e4f/32.png) [@vipbansa](https://dmap-community.ductus.global/u/vipbansa)\
**Post date:** [December 2, 2016, 6:58am UTC](https://dmap-community.ductus.global/t/facing-issues-in-implementing-get-next-call/866/3 "2016-12-02T06:58:22Z")

</div>

Hi,

I have added the printf in both the APi’s(get\_next and get\_elem).  
What i observed is get\_elem was not even called and get\_next is called twice with the same keypath value(I printed the keypath and its the same for both the times).

Both the times its hitting the same switch case and performing the same set of actions(I verified this by running GDB).

I have no clue as on why its stopped after the second iteration and why its sending -1 in next.

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [December 2, 2016, 9:57am UTC](https://dmap-community.ductus.global/t/facing-issues-in-implementing-get-next-call/866/4 "2016-12-02T09:57:16Z")

</div>

> [@vipbansa](#):
>
> \_elem was not even called and get\_next is called twice with the same keypath value(I printed the keypath and its the same for both the times).

As mentioned above, it is completely normal that get\_next() is invoked 2x with input parameter `next==-1`. ConfD can do it once to check whether e.g. list is not empty, and then 2nd time to start iterating the list.

You can verify whether something went wrong when displaying data in ConfD devel.log or confd.err log.

The iteration of list should not stop, assuming you did not send -1 as a `next` output parameter to ConfD.  
(unless other error makes it stop… - some ERR should be stated in devel.log/confd\_err.log)
