mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-17 16:47:50 +00:00
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>
This commit is contained in:
parent
332b945f79
commit
4b9b56b235
3 changed files with 21 additions and 5 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -130,6 +130,18 @@ struct libsoccr_sk_data {
|
|||
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
|
||||
*
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue