Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/soccr
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@virtuozzo.com>2016-12-14 12:41:14 +0300
committerPavel Emelyanov <xemul@virtuozzo.com>2017-01-16 11:04:49 +0300
commit4b9b56b2359da68d9b96a88c9c0b03876ff6d682 (patch)
treeb723531fe80fbb5be4ba626df0f326b94251a1c3 /soccr
parent332b945f79a4abbf1ffc1940f1148e9150b922e9 (diff)
soccr: Introduce flags for memory passing
There will be calls that return objects from inside library and vice versa -- accept objects from caller. Let's have a flag controlling who's going to free the mem in question. Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Acked-by: Andrei Vagin <avagin@virtuozzo.com>
Diffstat (limited to 'soccr')
-rw-r--r--soccr/soccr.c8
-rw-r--r--soccr/soccr.h14
2 files changed, 19 insertions, 3 deletions
diff --git a/soccr/soccr.c b/soccr/soccr.c
index fc5e280bd..d0c8668c4 100644
--- a/soccr/soccr.c
+++ b/soccr/soccr.c
@@ -354,10 +354,14 @@ int libsoccr_save(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, unsigne
return sizeof(struct libsoccr_sk_data);
}
-char *libsoccr_get_queue_bytes(struct libsoccr_sk *sk, int queue_id, int steal)
+#define GET_Q_FLAGS (SOCCR_MEM_EXCL)
+char *libsoccr_get_queue_bytes(struct libsoccr_sk *sk, int queue_id, unsigned flags)
{
char **p, *ret;
+ if (flags & ~GET_Q_FLAGS)
+ return NULL;
+
switch (queue_id) {
case TCP_RECV_QUEUE:
p = &sk->recv_queue;
@@ -370,7 +374,7 @@ char *libsoccr_get_queue_bytes(struct libsoccr_sk *sk, int queue_id, int steal)
}
ret = *p;
- if (steal)
+ if (flags & SOCCR_MEM_EXCL)
*p = NULL;
return ret;
diff --git a/soccr/soccr.h b/soccr/soccr.h
index 3ab7b905a..1e4bfb357 100644
--- a/soccr/soccr.h
+++ b/soccr/soccr.h
@@ -131,6 +131,18 @@ struct libsoccr_sk *libsoccr_pause(int fd);
void libsoccr_resume(struct libsoccr_sk *sk);
/*
+ * Flags for calls below
+ */
+
+/*
+ * Memory given to or taken from library is in exclusive ownership
+ * of the resulting owner. I.e. -- when taken by caller from library,
+ * the former will free() one, when given to the library, the latter
+ * is to free() it.
+ */
+#define SOCCR_MEM_EXCL 0x1
+
+/*
* CHECKPOINTING calls
*
* Roughly the checkpoint steps for sockets in supported states are
@@ -172,7 +184,7 @@ int libsoccr_save(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, unsigne
* library and should free() it himself. Otherwise the buffer can
* be claimed again and will be free by library upon _resume call.
*/
-char *libsoccr_get_queue_bytes(struct libsoccr_sk *sk, int queue_id, int steal);
+char *libsoccr_get_queue_bytes(struct libsoccr_sk *sk, int queue_id, unsigned flags);
/*
* RESTORING calls