Modernize header usage in bench_http.c

This commit is contained in:
Nick Mathewson 2010-10-18 13:53:31 -04:00
parent a8148cedcd
commit e5870690fc

View File

@ -25,8 +25,6 @@
* *
*/ */
#include "event2/event-config.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef WIN32 #ifdef WIN32
@ -44,15 +42,12 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <event.h> #include <event2/event.h>
#include <evutil.h> #include <event2/buffer.h>
#include <evhttp.h> #include <event2/util.h>
#include <event2/http.h>
#include <event2/thread.h> #include <event2/thread.h>
#ifdef WIN32
#include "iocp-internal.h"
#endif
static void http_basic_cb(struct evhttp_request *req, void *arg); static void http_basic_cb(struct evhttp_request *req, void *arg);
static char *content; static char *content;
@ -71,8 +66,7 @@ http_basic_cb(struct evhttp_request *req, void *arg)
evbuffer_free(evb); evbuffer_free(evb);
} }
/* cheasy way of detecting evbuffer_add_reference */ #if LIBEVENT_VERSION_NUMBER >= 0x02000200
#ifdef _EVENT2_EVENT_H_
static void static void
http_ref_cb(struct evhttp_request *req, void *arg) http_ref_cb(struct evhttp_request *req, void *arg)
{ {
@ -90,6 +84,7 @@ http_ref_cb(struct evhttp_request *req, void *arg)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
struct event_config *cfg = event_config_new();
struct event_base *base; struct event_base *base;
struct evhttp *http; struct evhttp *http;
int i; int i;
@ -105,8 +100,6 @@ main(int argc, char **argv)
return (1); return (1);
#endif #endif
base = event_base_new();
for (i = 1; i < argc; ++i) { for (i = 1; i < argc; ++i) {
if (*argv[i] != '-') if (*argv[i] != '-')
continue; continue;
@ -133,7 +126,7 @@ main(int argc, char **argv)
case 'i': case 'i':
use_iocp = 1; use_iocp = 1;
evthread_use_windows_threads(); evthread_use_windows_threads();
event_base_start_iocp(base, 0); event_config_set_flag(cfg,EVENT_BASE_FLAG_STARTUP_IOCP);
break; break;
#endif #endif
default: default:
@ -142,6 +135,12 @@ main(int argc, char **argv)
} }
} }
base = event_base_new_with_config(cfg);
if (!base) {
fprintf(stderr, "creating event_base failed. Exiting.\n");
return 1;
}
http = evhttp_new(base); http = evhttp_new(base);
content = malloc(content_len); content = malloc(content_len);