I want to record a key-value in persistent mode but when I want to use 2 or more different stores it doesn\'t work.
Here\'s my script:
...
t
John,
Your problem comes from the difficulty to play with pointers on pointers. We could fix this code but it will probably break later in your scripts because of its complexity.
For the long term, a simpler solution should be used to avoid bugs.
The structure attached to US_SERVER_DATA can be made simpler:
typedef struct
{
char *name;
kv_t *kv_1;
kv_t *kv_2;
void *callback;
u32 current_time;
}
This is the way to go: allocate memory with calloc(sizeof(my_struct));, and attach this structure to your US_SERVER_DATA pointer.
Then, providing you do all this in a G-WAN handler init() call (or in the gwan/main.c maintenance script, or even in the recently added gwan/init.c script), you will have exclusive access (one single thread is doing the initialization) and you will be able to attack G-WAN KV stores (and other objects) as needed.
If, later, G-WAN servlets or handlers are modifying these structure pointers then you will have to use a lock, spinlock, etc. or atomic variables for the pointers themselves.
Hope this helps.