in on callback function on_accept
, I make a event conn_ev
conn_ev = (struct event *)malloc(sizeof(struct event));
event_set(conn_ev, connfd, EV_READ, on_recv, conn_ev);
event_base_set(base, conn_ev);
event_add(conn_ev, NULL);
the callback function on_recv
will be triggered when there is a new connection.
and in the callback function on_recv(int connfd, short event, void *conn_event)
, I have
conn_ev = (struct event *) conn_event;
event_set(conn_ev, connfd, EV_WRITE, on_send, conn_ev);
event_base_set(base, conn_ev);
event_add(conn_ev, NULL);
so the conn_ev
is modified in this callback function.
are there any possible problem/trap here so that it is better I malloc
a new conn_ev?
thanks!