struct rspamc_callback_data {
struct rspamc_command *cmd;
gchar *filename;
- gdouble start;
};
gboolean
static void
rspamc_client_cb (struct rspamd_client_connection *conn,
- struct rspamd_http_message *msg,
- const gchar *name, ucl_object_t *result, GString *input,
- gpointer ud, GError *err)
+ struct rspamd_http_message *msg,
+ const gchar *name, ucl_object_t *result, GString *input,
+ gpointer ud, gdouble start_time, gdouble send_time,
+ GError *err)
{
gchar *ucl_out;
struct rspamc_callback_data *cbdata = (struct rspamc_callback_data *)ud;
gsize body_len;
cmd = cbdata->cmd;
- diff = finish - cbdata->start;
+
+ if (send_time > 0) {
+ diff = finish - send_time;
+ }
+ else {
+ diff = finish - start_time;
+ }
if (execute) {
/* Pass all to the external command */
cbdata = g_slice_alloc (sizeof (struct rspamc_callback_data));
cbdata->cmd = cmd;
cbdata->filename = g_strdup (name);
- cbdata->start = rspamd_get_ticks ();
if (cmd->need_input) {
rspamd_client_command (conn, cmd->path, attrs, in, rspamc_client_cb,
struct timeval timeout;
struct rspamd_http_connection *http_conn;
gboolean req_sent;
+ gdouble start_time;
+ gdouble send_time;
struct rspamd_client_request *req;
struct rspamd_keypair_cache *keys_cache;
};
struct rspamd_client_connection *c;
c = req->conn;
- req->cb (c, NULL, c->server_name->str, NULL, req->input, req->ud, err);
+ req->cb (c, NULL, c->server_name->str, NULL,
+ req->input, req->ud,
+ c->start_time, c->send_time, err);
}
static gint
if (!c->req_sent) {
c->req_sent = TRUE;
+ c->send_time = rspamd_get_ticks ();
rspamd_http_connection_reset (c->http_conn);
rspamd_http_connection_read_message (c->http_conn,
c->req,
err = g_error_new (RCLIENT_ERROR, msg->code, "HTTP error: %d, %.*s",
msg->code,
(gint)msg->status->len, msg->status->str);
- req->cb (c, msg, c->server_name->str, NULL, req->input, req->ud, err);
+ req->cb (c, msg, c->server_name->str, NULL, req->input, req->ud,
+ c->start_time, c->send_time, err);
g_error_free (err);
return 0;
"Decompression error: %s",
ZSTD_getErrorName (r));
req->cb (c, msg, c->server_name->str, NULL,
- req->input, req->ud, err);
+ req->input, req->ud, c->start_time,
+ c->send_time, err);
g_error_free (err);
ZSTD_freeDStream (zstream);
g_free (out);
err = g_error_new (RCLIENT_ERROR, msg->code, "Cannot parse UCL: %s",
ucl_parser_get_error (parser));
ucl_parser_free (parser);
- req->cb (c, msg, c->server_name->str, NULL, req->input, req->ud, err);
+ req->cb (c, msg, c->server_name->str, NULL, req->input,
+ req->ud, c->start_time, c->send_time, err);
g_error_free (err);
g_free (zout.dst);
err = g_error_new (RCLIENT_ERROR, 500,
"Invalid compression method");
req->cb (c, msg, c->server_name->str, NULL,
- req->input, req->ud, err);
+ req->input, req->ud, c->start_time, c->send_time, err);
g_error_free (err);
return 0;
err = g_error_new (RCLIENT_ERROR, msg->code, "Cannot parse UCL: %s",
ucl_parser_get_error (parser));
ucl_parser_free (parser);
- req->cb (c, msg, c->server_name->str, NULL, req->input, req->ud, err);
+ req->cb (c, msg, c->server_name->str, NULL,
+ req->input, req->ud, c->start_time, c->send_time, err);
g_error_free (err);
return 0;
}
req->cb (c, msg, c->server_name->str, ucl_parser_get_object (
- parser), req->input, req->ud, NULL);
+ parser), req->input, req->ud, c->start_time, c->send_time, NULL);
ucl_parser_free (parser);
}
req->msg->url = rspamd_fstring_append (req->msg->url, command, strlen (command));
conn->req = req;
+ conn->start_time = rspamd_get_ticks ();
if (compressed) {
rspamd_http_connection_write_message (conn->http_conn, req->msg, NULL,