priv->msg = req;
req->flags = flags;
+ if (flags & RSPAMD_HTTP_FLAG_SHMEM) {
+ req->body_buf.c.shared.shm_fd = -1;
+ }
+
if (priv->peer_key) {
priv->msg->peer_key = priv->peer_key;
priv->peer_key = NULL;
{
struct rspamd_storage_shmem *n = p;
+#ifdef HAVE_SANE_SHMEM
shm_unlink (n->shm_name);
+#else
+ unlink (n->shm_name);
+#endif
g_free (n->shm_name);
g_slice_free1 (sizeof (*n), n);
}
if (msg->flags & RSPAMD_HTTP_FLAG_SHMEM) {
storage->shared.name = g_slice_alloc (sizeof (*storage->shared.name));
REF_INIT_RETAIN (storage->shared.name, rspamd_http_shname_dtor);
+#ifdef HAVE_SANE_SHMEM
storage->shared.name->shm_name = g_strdup ("/rhm.XXXXXXXXXXXXXXXXXXXX");
storage->shared.shm_fd = rspamd_shmem_mkstemp (storage->shared.name->shm_name);
+#else
+ /* XXX: assume that tempdir is /tmp */
+ storage->shared.name->shm_name = g_strdup ("/tmp/rhm.XXXXXXXXXXXXXXXXXXXX");
+ storage->shared.shm_fd = mkstemp (storage->shared.name->shm_name);
+#endif
if (storage->shared.shm_fd == -1) {
return FALSE;
g_assert (fname != NULL);
g_assert (size != NULL);
+#ifdef HAVE_SANE_SHMEM
if (mode & PROT_WRITE) {
fd = shm_open (fname, O_RDWR, 0);
}
else {
fd = shm_open (fname, O_RDONLY, 0);
}
+#else
+ if (mode & PROT_WRITE) {
+ fd = open (fname, O_RDWR, 0);
+ }
+ else {
+ fd = open (fname, O_RDONLY, 0);
+ }
+#endif
if (fd == -1) {
return NULL;