in the libev ,I have initilized the io watcher to catch events and this event causes to store certain value in some cache. I have another timer watcher which runs every 10 sec, reads the cache value. In such case I suppose there is a race condition. do I need to use lock in two different libev watcher or libev handles it.
eg:
TCP_CACHE_TIMEOUT = g_hash_table_new_full(g_str_hash, g_int_equal, key_destroy_cb, value_destroy_timeoutcb);
zlog_info(_c,"TCP Server started at _port: %d",_port);
int fd =setup_tcp_socket(_port);
if(fd<0)
{
return NULL;
}
struct ev_loop *loop = EV_DEFAULT;
struct _sock_ev_serv server;
server.fd = fd;
ev_io_init(&server.io, event_server, server.fd, EV_READ);
ev_io_start(EV_A_ &server.io);
ev_timer_init (&timeout_watcher, timeout_idle_fd, 0, 10.);
ev_timer_again (loop,&timeout_watcher);
ev_loop(loop, 0);
here I have loop and initilizes io watcher to accept server event, and timer watcher to look in the cache every 10 sec. In such case Do I need to handle the race condition myself or the two watcher io and timer running time is managed by libev?