A particular notification CONFD_SET_STR is setting the string as “%” am not sure why. The log level(developer LOG level set to trace) also did not give me any specific information about it.
The string before the notification CONFD_SET_STR seems fine.
" Radar channels 124 140 120 116 at time Wed Mar 8 11:09:31 2017 detected "
Its a very wierd behavior. I am not sure the scenario when the notification becomes “%”. Sometimes the notification is seen, sometimes it just displays “%”.
Did you allocate the my_tv_array properly? Are you providing the correct prefix+tag from your header file, i.e. myprefix_mytagname? Is the formatting of mystring indeed correct?
You can check the contents of the tag value array, here my_tv_array[], before sending it:
No, you can’t set the value as C_STR and expect to get it back as C_BUF, they are different confd_value_t types even though they are both used to repsent the ‘string’ YANG type. Basically libconfd will always create C_BUF values, C_STR is a convenience for the programmer.
Perhaps the memory was freed and overwritten before the notification had actually been sent?
See confd_lib_types(3) man page and look for C_BUF and C_STR for more info.
If you can give us some YANG snippet and code so that we can recreate your issue, we might be able to figure out what happened.
Well, the requirement from the libconfd library is only that the memory is valid for the duration of the confd_notification_send() call - and the library dosn’t free the data passed to the function, nor does it even care where it lives (heap/stack/constant/global).
ITYM confd_types(3) - but I’m not sure the discussion about memory management there is relevant, it’s about how memory for strings must be allocated by the library when reading via MAAPI or CDB API, and the application thus is responsible for releasing that memory with confd_free_value().
In the case of confd_notification_send(), it is entirely up to the application to manage the memory for the tag-value array - allocating before the call if needed, freeing after the call if allocated.
This requirement is clearly not fulfilled by your code:
CONFD_SET_TAG_STR() just stores a pointer to your dynamically allocated buffer in the tag-value array. You need to ensure that the buffer remains valid until you have called confd_notification_send(), and since you delete it here before returning the array (which is eventually used for the confd_notification_send() call by some higher-up function), you obviously aren’t doing that.