Skip to content
Snippets Groups Projects
Commit 1aadbe4e authored by Moe Jette's avatar Moe Jette
Browse files

Add (optional) memory release on shutdown to more easily track memory leaks.

parent c60a28bd
No related branches found
No related tags found
No related merge requests found
......@@ -103,6 +103,7 @@ typedef struct task_info {
} task_info_t;
static void alarm_handler(int dummy);
static void list_delete_retry (void *retry_entry);
static void queue_agent_retry (agent_info_t *agent_info_ptr, int count);
static void slurmctld_free_job_launch_msg(batch_job_launch_msg_t * msg);
static void spawn_retry_agent (agent_arg_t *agent_arg_ptr);
......@@ -195,7 +196,7 @@ agent (void *args)
&agent_info_ptr->thread_mutex);
}
/* create thread, note this is freed from thread_per_node_rpc() */
/* create thread specific dat, NOTE freed from thread_per_node_rpc() */
task_specific_ptr = xmalloc (sizeof (task_info_t));
task_specific_ptr->thread_mutex_ptr = &agent_info_ptr->thread_mutex;
task_specific_ptr->thread_cond_ptr = &agent_info_ptr->thread_cond;
......@@ -530,7 +531,7 @@ queue_agent_retry (agent_info_t *agent_info_ptr, int count)
/* add the requeust to a list */
pthread_mutex_lock (&retry_mutex);
if (retry_list == NULL) {
retry_list = list_create (NULL);
retry_list = list_create (&list_delete_retry);
if (retry_list == NULL)
fatal ("list_create failed");
}
......@@ -539,6 +540,28 @@ queue_agent_retry (agent_info_t *agent_info_ptr, int count)
pthread_mutex_unlock (&retry_mutex);
}
/*
* list_delete_retry - delete an entry from the retry list,
* see common/list.h for documentation
*/
void
list_delete_retry (void *retry_entry)
{
agent_arg_t *agent_arg_ptr; /* pointer to part_record */
agent_arg_ptr = (agent_arg_t *) retry_entry;
if (agent_arg_ptr -> slurm_addr)
xfree (agent_arg_ptr -> slurm_addr);
if (agent_arg_ptr -> node_names)
xfree (agent_arg_ptr -> node_names);
#if AGENT_IS_THREAD
if (agent_arg_ptr -> msg_args)
xfree (agent_arg_ptr -> msg_args);
#endif
xfree (agent_arg_ptr);
}
/* agent_retry - Agent for retrying pending RPCs (top one on the queue),
* argument is unused */
void *
......@@ -634,3 +657,14 @@ void slurmctld_free_job_launch_msg(batch_job_launch_msg_t * msg)
}
}
/* agent_purge - purge all pending RPC requests */
void agent_purge (void)
{ retry_list = list_create (NULL);
pthread_mutex_lock (&retry_mutex);
if (retry_list == NULL)
list_destroy (retry_list);
pthread_mutex_unlock (&retry_mutex);
}
......@@ -56,4 +56,7 @@ extern void *agent_retry (void *args);
/* retry_pending - retry all pending RPCs for the given node name */
extern void retry_pending (char *node_name);
/* agent_purge - purge all pending RPC requests */
extern void agent_purge (void);
#endif /* !_AGENT_H */
......@@ -57,6 +57,7 @@
#define DEFAULT_DAEMONIZE 0
#define DEFAULT_RECOVER 0
#define MAX_SERVER_THREAD_COUNT 20
#define MEM_LEAK_TEST 0
/* Log to stderr and syslog until becomes a daemon */
log_options_t log_opts = { 1, LOG_LEVEL_INFO, LOG_LEVEL_INFO, LOG_LEVEL_QUIET } ;
......@@ -470,6 +471,25 @@ slurmctld_background ( void * no_data )
}
debug3 ("slurmctld_background shutting down");
#if MEM_LEAK_TEST
/* This should purge all allocated memory, *\
\* Anything left over represents a leak. */
if (job_list)
list_destroy (job_list);
if (part_list)
list_destroy (part_list);
if (config_list)
list_destroy (config_list);
if (node_record_table_ptr)
xfree (node_record_table_ptr);
if (hash_table)
xfree (hash_table);
agent_purge ();
#endif
return NULL;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment