o Add new thread-safe interfaces to evdns functions.
o Make all event_tagging interfaces threadsafe.
o Rename internal memory management functions.
+ o New functions (event_assign, event_new, event_free) for use by apps that want to be safely threadsafe, or want to remain ignorant of the contents of struct event.
Changes in 1.4.0:
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
return (0);
}
+int
+event_assign(struct event *ev, struct event_base *base, evutil_socket_t fd, short events, void (*cb)(evutil_socket_t, short, void *), void *arg)
+{
+ event_set(ev, fd, events, cb, arg);
+ return event_base_set(base, ev);
+}
+
+struct event *
+event_new(struct event_base *base, evutil_socket_t fd, short events, void (*cb)(evutil_socket_t, short, void *), void *arg)
+{
+ struct event *ev;
+ ev = mm_malloc(sizeof(struct event));
+ if (!ev)
+ return NULL;
+ if (event_assign(ev, base, fd, events, cb, arg) < 0) {
+ mm_free(ev);
+ return NULL;
+ }
+ return ev;
+}
+
+void
+event_free(struct event *ev)
+{
+ /* make sure that this event won't be coming back to haunt us.
+ * XXX this is safe, right? */
+ event_del(ev);
+ mm_free(ev);
+}
+
/*
* Set's the priority of an event - if an event is already scheduled
* changing the priority is going to fail.
*/
void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
+/*XXX document this function, deprecate previous one. */
+int event_assign(struct event *, struct event_base *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
+
+struct event *event_new(struct event_base *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
+
+void event_free(struct event *);
+
/**
Schedule a one-time event (threadsafe variant)