Browse Source

Fix benchmarks

pull/523/head
Vsevolod Stakhov 10 years ago
parent
commit
81e728813b
  1. 20
      utils/CMakeLists.txt
  2. 20
      utils/rspamd_http_bench.c
  3. 19
      utils/rspamd_http_server.c

20
utils/CMakeLists.txt

@ -1,17 +1,17 @@
SET(UTILSERVERSRC rspamd_http_server.c)
SET(UTILBENCHSRC rspamd_http_bench.c)
#ADD_EXECUTABLE(rspamd-http-server ${UTILSERVERSRC})
#SET_TARGET_PROPERTIES(rspamd-http-server PROPERTIES LINKER_LANGUAGE C)
#TARGET_LINK_LIBRARIES(rspamd-http-server rspamd-server)
#TARGET_LINK_LIBRARIES(rspamd-http-server rspamd-http-parser)
#TARGET_LINK_LIBRARIES(rspamd-http-server ${RSPAMD_REQUIRED_LIBRARIES})
ADD_EXECUTABLE(rspamd-http-server ${UTILSERVERSRC})
SET_TARGET_PROPERTIES(rspamd-http-server PROPERTIES LINKER_LANGUAGE C)
TARGET_LINK_LIBRARIES(rspamd-http-server rspamd-server)
TARGET_LINK_LIBRARIES(rspamd-http-server rspamd-http-parser)
TARGET_LINK_LIBRARIES(rspamd-http-server ${RSPAMD_REQUIRED_LIBRARIES})
#ADD_EXECUTABLE(rspamd-http-bench ${UTILBENCHSRC})
#SET_TARGET_PROPERTIES(rspamd-http-bench PROPERTIES LINKER_LANGUAGE C)
#TARGET_LINK_LIBRARIES(rspamd-http-bench rspamd-server)
#TARGET_LINK_LIBRARIES(rspamd-http-bench rspamd-http-parser)
#TARGET_LINK_LIBRARIES(rspamd-http-bench ${RSPAMD_REQUIRED_LIBRARIES})
ADD_EXECUTABLE(rspamd-http-bench ${UTILBENCHSRC})
SET_TARGET_PROPERTIES(rspamd-http-bench PROPERTIES LINKER_LANGUAGE C)
TARGET_LINK_LIBRARIES(rspamd-http-bench rspamd-server)
TARGET_LINK_LIBRARIES(rspamd-http-bench rspamd-http-parser)
TARGET_LINK_LIBRARIES(rspamd-http-bench ${RSPAMD_REQUIRED_LIBRARIES})
# Redirector
IF (ENABLE_REDIRECTOR MATCHES "ON")

20
utils/rspamd_http_bench.c

@ -131,7 +131,9 @@ rspamd_client_finish (struct rspamd_http_connection *conn,
static void
rspamd_http_client_func (struct event_base *ev_base, struct lat_elt *latency,
guint32 *wconns,
gpointer peer_key, gpointer client_key, struct rspamd_keypair_cache *c)
struct rspamd_cryptobox_pubkey *peer_key,
struct rspamd_cryptobox_keypair* client_key,
struct rspamd_keypair_cache *c)
{
struct rspamd_http_message *msg;
struct rspamd_http_connection *conn;
@ -154,7 +156,7 @@ rspamd_http_client_func (struct event_base *ev_base, struct lat_elt *latency,
if (peer_key != NULL) {
g_assert (client_key != NULL);
rspamd_http_connection_set_key (conn, client_key);
msg->peer_key = rspamd_http_connection_key_ref (peer_key);
msg->peer_key = rspamd_pubkey_ref (peer_key);
}
cb = g_malloc (sizeof (*cb));
@ -174,13 +176,15 @@ rspamd_worker_func (struct lat_elt *plat, guint32 *wconns)
struct event_base *ev_base;
struct itimerval itv;
struct rspamd_keypair_cache *c = NULL;
gpointer client_key = NULL;
gpointer peer_key = NULL;
struct rspamd_cryptobox_keypair *client_key = NULL;
struct rspamd_cryptobox_pubkey *peer_key = NULL;
if (server_key) {
peer_key = rspamd_http_connection_make_peer_key (server_key);
peer_key = rspamd_pubkey_from_base32 (server_key, 0, RSPAMD_KEYPAIR_KEX,
openssl_mode ? RSPAMD_CRYPTOBOX_MODE_NIST : RSPAMD_CRYPTOBOX_MODE_25519);
g_assert (peer_key != NULL);
client_key = rspamd_http_connection_gen_key ();
client_key = rspamd_keypair_new (RSPAMD_KEYPAIR_KEX,
openssl_mode ? RSPAMD_CRYPTOBOX_MODE_NIST : RSPAMD_CRYPTOBOX_MODE_25519);
if (cache_size > 0) {
c = rspamd_keypair_cache_new (cache_size);
@ -329,10 +333,6 @@ main (int argc, char **argv)
exit (1);
}
if (openssl_mode) {
g_assert (rspamd_cryptobox_openssl_mode (TRUE));
}
rspamd_parse_inet_address (&addr, host, 0);
g_assert (addr != NULL);
rspamd_inet_address_set_port (addr, port);

19
utils/rspamd_http_server.c

@ -19,6 +19,7 @@
#include "http.h"
#include "ottery.h"
#include "cryptobox.h"
#include "keypair.h"
#include "unix-std.h"
#include <math.h>
@ -33,7 +34,7 @@ static gboolean openssl_mode = FALSE;
static GHashTable *maps = NULL;
static gchar *key = NULL;
static struct rspamd_keypair_cache *c;
static gpointer server_key;
static struct rspamd_cryptobox_keypair *server_key;
static struct timeval io_tv = {
.tv_sec = 20,
.tv_usec = 0
@ -260,23 +261,15 @@ main (int argc, gchar **argv)
maps = g_hash_table_new (g_int_hash, g_int_equal);
if (openssl_mode) {
g_assert (rspamd_cryptobox_openssl_mode (TRUE));
}
if (key == NULL) {
server_key = rspamd_http_connection_gen_key ();
b32_key = rspamd_http_connection_print_key (server_key,
server_key = rspamd_keypair_new (RSPAMD_KEYPAIR_KEX,
openssl_mode ? RSPAMD_CRYPTOBOX_MODE_NIST : RSPAMD_CRYPTOBOX_MODE_25519);
b32_key = rspamd_keypair_print (server_key,
RSPAMD_KEYPAIR_PUBKEY | RSPAMD_KEYPAIR_BASE32);
rspamd_printf ("key: %v\n", b32_key);
}
else {
server_key = rspamd_http_connection_make_key (key, strlen (key));
if (server_key == NULL) {
rspamd_fprintf (stderr, "cannot load key %s\n", key);
exit (EXIT_FAILURE);
}
/* TODO: add key loading */
}
if (cache_size > 0) {

Loading…
Cancel
Save