diff --git a/external/source/meterpreter/source/common/list.c b/external/source/meterpreter/source/common/list.c index ba780b8c9f..20f73b2a1f 100644 --- a/external/source/meterpreter/source/common/list.c +++ b/external/source/meterpreter/source/common/list.c @@ -2,9 +2,9 @@ /* * An implementation of a simple thread safe double linked list structure. Can be used as either - * a stack (via pop/push) or an array (via get/add/insert/remove). If performing a group of - * actions on a list based on results from list actions, acquire the list lock before the group - * of actions and release lock when done. + * a stack (via pop/push), a queue (via push/shift) or an array (via get/add/insert/remove). If + * performing a group of actions on a list based on results from list actions, acquire the list + * lock before the group of actions and release lock when done. */ /* @@ -308,5 +308,29 @@ LPVOID list_pop( LIST * list ) lock_release( list->lock ); + return data; +} + +/* + * Pop a data value off the start of the list. + */ +LPVOID list_shift( LIST * list ) +{ + LPVOID data = NULL; + + if( list == NULL ) + return NULL; + + lock_acquire( list->lock ); + + if( list->start != NULL ) + { + data = list->start->data; + + list_remove_node( list, list->start ); + } + + lock_release( list->lock ); + return data; } \ No newline at end of file diff --git a/external/source/meterpreter/source/common/list.h b/external/source/meterpreter/source/common/list.h index 0c7866ad0c..fbb228ea5e 100644 --- a/external/source/meterpreter/source/common/list.h +++ b/external/source/meterpreter/source/common/list.h @@ -38,6 +38,8 @@ BOOL list_push( LIST * list, LPVOID data ); LPVOID list_pop( LIST * list ); +LPVOID list_shift( LIST * list ); + /*****************************************************************************************/ #endif \ No newline at end of file