|
|
@ -18,7 +18,25 @@ typedef struct sandbox_request sandbox_request_t;
|
|
|
|
|
|
|
|
|
|
|
|
DEQUE_PROTOTYPE(sandbox, sandbox_request_t *);
|
|
|
|
DEQUE_PROTOTYPE(sandbox, sandbox_request_t *);
|
|
|
|
|
|
|
|
|
|
|
|
static inline int add_sandbox_request_to_global_dequeue(sandbox_request_t *sandbox_request);
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Pushes a sandbox request to the global deque
|
|
|
|
|
|
|
|
* @param sandbox_request
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
|
|
|
|
sandbox_request__add_to_global_dequeue(sandbox_request_t *sandbox_request)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int return_code;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if NCORES == 1
|
|
|
|
|
|
|
|
pthread_mutex_lock(&global_deque_mutex);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return_code = deque_push_sandbox(global_deque, &sandbox_request);
|
|
|
|
|
|
|
|
#if NCORES == 1
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&global_deque_mutex);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return return_code;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Allocates a new Sandbox Request and places it on the Global Deque
|
|
|
|
* Allocates a new Sandbox Request and places it on the Global Deque
|
|
|
@ -30,7 +48,7 @@ static inline int add_sandbox_request_to_global_dequeue(sandbox_request_t *sandb
|
|
|
|
* @return the new sandbox request
|
|
|
|
* @return the new sandbox request
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
static inline sandbox_request_t *
|
|
|
|
static inline sandbox_request_t *
|
|
|
|
allocate_sandbox_request(struct module *module, char *arguments, int socket_descriptor, const struct sockaddr *socket_address, u64 start_time)
|
|
|
|
sandbox_request__allocate(struct module *module, char *arguments, int socket_descriptor, const struct sockaddr *socket_address, u64 start_time)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sandbox_request_t *sandbox_request = (sandbox_request_t *)malloc(sizeof(sandbox_request_t));
|
|
|
|
sandbox_request_t *sandbox_request = (sandbox_request_t *)malloc(sizeof(sandbox_request_t));
|
|
|
|
assert(sandbox_request);
|
|
|
|
assert(sandbox_request);
|
|
|
@ -41,36 +59,16 @@ allocate_sandbox_request(struct module *module, char *arguments, int socket_desc
|
|
|
|
sandbox_request->start_time = start_time;
|
|
|
|
sandbox_request->start_time = start_time;
|
|
|
|
|
|
|
|
|
|
|
|
debuglog("[%p: %s]\n", sandbox_request, sandbox_request->module->name);
|
|
|
|
debuglog("[%p: %s]\n", sandbox_request, sandbox_request->module->name);
|
|
|
|
add_sandbox_request_to_global_dequeue(sandbox_request);
|
|
|
|
sandbox_request__add_to_global_dequeue(sandbox_request);
|
|
|
|
return sandbox_request;
|
|
|
|
return sandbox_request;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Pushes a sandbox request to the global deque
|
|
|
|
|
|
|
|
* @param sandbox_request
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
|
|
|
|
add_sandbox_request_to_global_dequeue(sandbox_request_t *sandbox_request)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int return_code;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if NCORES == 1
|
|
|
|
|
|
|
|
pthread_mutex_lock(&global_deque_mutex);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return_code = deque_push_sandbox(global_deque, &sandbox_request);
|
|
|
|
|
|
|
|
#if NCORES == 1
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&global_deque_mutex);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return return_code;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Pops a sandbox request from the global deque
|
|
|
|
* Pops a sandbox request from the global deque
|
|
|
|
* @param sandbox_request the pointer which we want to set to the sandbox request
|
|
|
|
* @param sandbox_request the pointer which we want to set to the sandbox request
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
static inline int
|
|
|
|
static inline int
|
|
|
|
pop_sandbox_request_from_global_dequeue(sandbox_request_t **sandbox_request)
|
|
|
|
sandbox_request__pop_from_global_dequeue(sandbox_request_t **sandbox_request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int return_code;
|
|
|
|
int return_code;
|
|
|
|
|
|
|
|
|
|
|
@ -84,18 +82,17 @@ pop_sandbox_request_from_global_dequeue(sandbox_request_t **sandbox_request)
|
|
|
|
return return_code;
|
|
|
|
return return_code;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* TODO: What does this do?
|
|
|
|
* TODO: What does this do?
|
|
|
|
* @returns A Sandbox Request or NULL
|
|
|
|
* @returns A Sandbox Request or NULL
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
static inline sandbox_request_t *
|
|
|
|
static inline sandbox_request_t *
|
|
|
|
steal_sandbox_request_from_global_dequeue(void)
|
|
|
|
sandbox_request__steal_from_global_dequeue(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sandbox_request_t *sandbox_request = NULL;
|
|
|
|
sandbox_request_t *sandbox_request = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
#if NCORES == 1
|
|
|
|
#if NCORES == 1
|
|
|
|
pop_sandbox_request_from_global_dequeue(&sandbox_request);
|
|
|
|
sandbox_request__pop_from_global_dequeue(&sandbox_request);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
int r = deque_steal_sandbox(global_deque, &sandbox_request);
|
|
|
|
int r = deque_steal_sandbox(global_deque, &sandbox_request);
|
|
|
|
if (r) sandbox_request = NULL;
|
|
|
|
if (r) sandbox_request = NULL;
|
|
|
|