]> granicus.if.org Git - libevent/blob - whatsnew-2.2.txt
cmake: Fix Android build.
[libevent] / whatsnew-2.2.txt
1 ...
2
3 * Building libevent as a sub-project using GNU Auto* tools
4
5 Some projects will choose to include libevent in their source distribution,
6 and build libevent as a sub-project.  This may be effected by putting the
7 line:
8
9  AC_CONFIG_SUBDIRS([path/to/libevent])
10
11 in the master configure.ac file for the master project.
12
13 There are cases where the master project will want to pass in additional
14 flags for CFLAGS, CPPFLAGS, or LDFLAGS.  Since these variables are reserved
15 for the user, and AM_CFLAGS, AM_CPPFLAGS, and AM_LDFLAGS are reserved for
16 each package, libevent offers the following variables for a master package
17 to tell libevent that there are additional compile/link values:
18
19  LIBEVENT_CFLAGS
20  LIBEVENT_CPPFLAGS
21  LIBEVENT_LDFLAGS
22
23 A master package can set these variables in its configure.ac file.
24
25 Here's an example:
26
27 configure.ac:
28 ...
29 EXTRA_CFLAGS=...
30 EXTRA_CPPFLAGS=...
31 EXTRA_LDFLAGS=...
32 ...
33 dnl ac_configure_args is undocumented but widely abused, as here,
34 dnl to modify the defaults of the libevent subpackage, by prefixing
35 dnl our changes to the child configure arguments already assembled.
36 dnl User-supplied contradictory choices should prevail thanks to
37 dnl "last wins".
38 ac_configure_args=" --disable-openssl${ac_configure_args}"
39 ac_configure_args=" --disable-shared${ac_configure_args}"
40 ac_configure_args=" --disable-libevent-regress${ac_configure_args}"
41 ac_configure_args=" --disable-libevent-install${ac_configure_args}"
42 ac_configure_args=" --enable-silent-rules${ac_configure_args}"
43 ac_configure_args=" --enable-function-sections${ac_configure_args}"
44 ac_configure_args=" LIBEVENT_CFLAGS='${EXTRA_CFLAGS}'${ac_configure_args}"
45 ac_configure_args=" LIBEVENT_CPPFLAGS='${EXTRA_CPPFLAGS}'${ac_configure_args}"
46 ac_configure_args=" LIBEVENT_LDFLAGS='${EXTRA_LDFLAGS}'${ac_configure_args}"
47 AC_CONFIG_SUBDIRS([libevent])
48 ...
49
50 The space after the initial '"' is significant.
51
52 * "Prepare" and "check" watchers
53
54 Libevent now has a new mechanism for hooking into the event loop: "prepare" and
55 "check" watchers.  A "prepare" watcher is a callback that fires immediately
56 before polling for I/O. A "check" watcher is a callback that fires immediately
57 after polling and before processing any active events. This may be useful for
58 embedding other libraries' event loops (e.g. UI toolkits) into libevent's. It's
59 also useful for monitoring server performance. For example, if you measure the
60 time between "prepare" and "check," that is the polling duration; the difference
61 between the expected and actual polling duration provides an indication of
62 kernel scheduling delay. And if you measure the time between "check" and the
63 next "prepare" (in the next iteration of the event loop), that is a good
64 approximation of the amount of time handling events; this provides a convenient
65 way to monitor whether any event handlers are blocking or otherwise performing
66 heavy computation.
67
68 The watcher API is defined in <event2/watch.h>. A concrete example of how
69 watchers can help monitor server performance is available in
70 "sample/watch-timing.c".
71
72 * Support for custom HTTP methods
73
74 Libevent HTTP code now supports defining custom HTTP methods. It is done
75 through a callback:
76
77   #define EVHTTP_REQ_CUSTOM      ((EVHTTP_REQ_MAX) << 1)
78   static int ext_method_cb(struct evhttp_ext_method *p)
79   {
80     if (p == NULL)
81       return -1;
82     if (p->method) {
83       if (strcmp(p->method, "CUSTOM") == 0) {
84         p->type = EVHTTP_REQ_CUSTOM;
85         p->flags = 0;   /*EVHTTP_METHOD_HAS_BODY*/
86         return 0;
87       }
88     } else {
89       if (p->type == EVHTTP_REQ_CUSTOM) {
90         p->method = "CUSTOM";
91         return 0;
92       }
93     }
94   }
95
96 And to register this callback with http server you can use:
97   evhttp_set_ext_method_cmp(http, ext_method_cb);
98
99 Or registering callback with one client only:
100   evhttp_connection_set_ext_method_cmp(evcon, ext_method_cb);