#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>
|
|
static void * server_sockt;
|
|
static void stop_bus_handler(int sig) {
|
bus_server_socket_wrapper_stop(server_sockt);
|
}
|
|
static void *_start_bus_(void *arg) {
|
pthread_detach(pthread_self());
|
printf("Start bus server\n");
|
pthread_t tid;
|
|
if(bus_server_socket_wrapper_start_bus(server_sockt) != 0) {
|
printf("start bus failed\n");
|
}
|
|
bus_server_socket_wrapper_close(server_sockt);
|
printf("============bus stopted\n" );
|
}
|
|
|
int main() {
|
pthread_t tid;
|
char action[512];
|
signal(SIGINT, stop_bus_handler);
|
signal(SIGTERM, stop_bus_handler);
|
shm_mm_wrapper_init(512);
|
server_sockt = bus_server_socket_wrapper_open();
|
pthread_create(&tid, NULL, _start_bus_, NULL);
|
|
|
// while (true) {
|
// printf("Input action: Close?\n");
|
// if(scanf("%s", action) < 1) {
|
// printf("Invalide action\n");
|
// continue;
|
// }
|
|
// if(strcmp(action, "close") == 0) {
|
// bus_server_socket_wrapper_close(server_sockt);
|
// break;
|
// } else {
|
// printf("Invalide action\n");
|
// }
|
// }
|
|
if (pthread_join(tid, NULL) != 0) {
|
perror(" pthread_join");
|
}
|
|
|
shm_mm_wrapper_destroy();
|
}
|