priv->peer_key = msg->peer_key;
msg->peer_key = NULL;
}
- rspamd_http_message_free (msg);
+ rspamd_http_message_unref (msg);
priv->msg = NULL;
}
}
struct rspamd_http_message *
-rspamd_http_connection_copy_msg (struct rspamd_http_connection *conn)
+rspamd_http_connection_copy_msg (struct rspamd_http_message *msg)
{
- struct rspamd_http_connection_private *priv;
- struct rspamd_http_message *new_msg, *msg;
+ struct rspamd_http_message *new_msg;
struct rspamd_http_header *hdr, *nhdr, *thdr;
const gchar *old_body;
gsize old_len;
struct stat st;
union _rspamd_storage_u *storage;
- priv = conn->priv;
- msg = priv->msg;
-
new_msg = rspamd_http_new_message (msg->type);
new_msg->flags = msg->flags;
storage->shared.shm_fd = dup (msg->body_buf.c.shared.shm_fd);
if (storage->shared.shm_fd == -1) {
- rspamd_http_message_free (new_msg);
+ rspamd_http_message_unref (new_msg);
return NULL;
}
if (fstat (storage->shared.shm_fd, &st) == -1) {
- rspamd_http_message_free (new_msg);
+ rspamd_http_message_unref (new_msg);
return NULL;
}
storage->shared.shm_fd, 0);
if (new_msg->body_buf.str == MAP_FAILED) {
- rspamd_http_message_free (new_msg);
+ rspamd_http_message_unref (new_msg);
return NULL;
}
old_body = rspamd_http_message_get_body (msg, &old_len);
if (!rspamd_http_message_set_body (new_msg, old_body, old_len)) {
- rspamd_http_message_free (new_msg);
+ rspamd_http_message_unref (new_msg);
return NULL;
}
}
new->type = type;
new->method = HTTP_GET;
+ REF_INIT_RETAIN (new, rspamd_http_message_free);
+
return new;
}
msg->host = rspamd_fstring_new_init (host, pu.field_data[UF_HOST].len);
msg->url = rspamd_fstring_append (msg->url, path, pathlen);
+ REF_INIT_RETAIN (msg, rspamd_http_message_free);
+
return msg;
}
http_month[tms.tm_mon], tms.tm_year + 1900,
tms.tm_hour, tms.tm_min, tms.tm_sec);
}
+
+struct rspamd_http_message *
+rspamd_http_message_ref (struct rspamd_http_message *msg)
+{
+ REF_RETAIN (msg);
+
+ return msg;
+}
+
+void
+rspamd_http_message_unref (struct rspamd_http_message *msg)
+{
+ REF_RELEASE (msg);
+}
* @return
*/
struct rspamd_http_message * rspamd_http_connection_copy_msg (
- struct rspamd_http_connection *conn);
+ struct rspamd_http_message *msg);
/**
* Create new HTTP message
*/
struct rspamd_http_message * rspamd_http_new_message (enum http_parser_type type);
+/**
+ * Increase refcount number for an HTTP message
+ * @param msg message to use
+ * @return
+ */
+struct rspamd_http_message * rspamd_http_message_ref (struct rspamd_http_message *msg);
+/**
+ * Decrease number of refcounts for http message
+ * @param msg
+ */
+void rspamd_http_message_unref (struct rspamd_http_message *msg);
/**
* Create HTTP message from URL
* @param url