]> arthur.barton.de Git - netatalk.git/blobdiff - libevent/test/test-ratelim.c
fce: afpd: fix event names array
[netatalk.git] / libevent / test / test-ratelim.c
index 824434e08959616a1de40b2a591799acfcbb910f..eb0b165471d1a21375d52485233abffa3f2158fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2010 Niels Provos and Nick Mathewson
+ * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,9 @@
 #else
 #include <sys/socket.h>
 #include <netinet/in.h>
+# ifdef _XOPEN_SOURCE_EXTENDED
+#  include <arpa/inet.h>
+# endif
 #endif
 #include <signal.h>
 
@@ -46,6 +49,8 @@
 #include "event2/listener.h"
 #include "event2/thread.h"
 
+#include "../util-internal.h"
+
 static int cfg_verbose = 0;
 static int cfg_help = 0;
 
@@ -60,6 +65,10 @@ static int cfg_connlimit_tolerance = -1;
 static int cfg_grouplimit_tolerance = -1;
 static int cfg_stddev_tolerance = -1;
 
+#ifdef _WIN32
+static int cfg_enable_iocp = 0;
+#endif
+
 static struct timeval cfg_tick = { 0, 500*1000 };
 
 static struct ev_token_bucket_cfg *conn_bucket_cfg = NULL;
@@ -181,6 +190,7 @@ test_ratelimiting(void)
        double variance;
        double expected_total_persec = -1.0, expected_avg_persec = -1.0;
        int ok = 1;
+       struct event_config *base_cfg;
 
        memset(&sin, 0, sizeof(sin));
        sin.sin_family = AF_INET;
@@ -190,7 +200,16 @@ test_ratelimiting(void)
        if (0)
                event_enable_debug_mode();
 
-       base = event_base_new();
+       base_cfg = event_config_new();
+
+#ifdef _WIN32
+       if (cfg_enable_iocp) {
+               evthread_use_windows_threads();
+               event_config_set_flag(base_cfg, EVENT_BASE_FLAG_STARTUP_IOCP);
+       }
+#endif
+
+       base = event_base_new_with_config(base_cfg);
 
        listener = evconnlistener_new_bind(base, echo_listenercb, base,
            LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, -1,
@@ -344,6 +363,9 @@ static struct option {
        { "--check-connlimit", &cfg_connlimit_tolerance, 0, 0 },
        { "--check-grouplimit", &cfg_grouplimit_tolerance, 0, 0 },
        { "--check-stddev", &cfg_stddev_tolerance, 0, 0 },
+#ifdef _WIN32
+       { "--iocp", &cfg_enable_iocp, 0, 1 },
+#endif
        { NULL, NULL, -1, 0 },
 };