#include <assert.h>
|
#include "net_mod_server_socket_wrapper.h"
|
#include "net_mod_socket_wrapper.h"
|
#include "bus_server_socket_wrapper.h"
|
|
#include "shm_mm_wrapper.h"
|
#include "usg_common.h"
|
#include <getopt.h>
|
#include "logger_factory.h"
|
|
|
static void usage(const char *name) {
|
printf("Usage: %s {list}\n", name);
|
|
}
|
|
|
void list () {
|
hashtable_t *hashtable = mm_get_hashtable();
|
hashtable_foreach(hashtable, [&](int key, void * value){
|
printf("%d\n", key);
|
});
|
}
|
|
|
void remove(int key) {
|
hashtable_t *hashtable = mm_get_hashtable();
|
|
LockFreeQueue<shm_packet_t> * mqueue = (LockFreeQueue<shm_packet_t> *)hashtable_get(hashtable, key);
|
if(mqueue != NULL) {
|
delete mqueue;
|
hashtable_remove(hashtable, key);
|
}
|
}
|
|
int main(int argc, char *argv[]) {
|
shm_mm_wrapper_init(512);
|
int key;
|
int i;
|
if(argc < 2) {
|
usage(argv[0]);
|
return 1;
|
}
|
|
if(strcmp(argv[1], "list") == 0) {
|
list();
|
}
|
else if(strcmp(argv[1], "rm") == 0) {
|
if(argc < 3) {
|
usage(argv[0]);
|
return 1;
|
}
|
for(i = 2; i < argc; i++) {
|
key = atoi(argv[i]);
|
remove(key);
|
}
|
|
}
|
|
shm_mm_wrapper_destroy();
|
|
|
}
|