| | |
| | | #include "bus_server_socket_wrapper.h" |
| | | #include "shm_mm_wrapper.h" |
| | | #include "proc_def.h" |
| | | #include "mm.h" |
| | | #include "usg_common.h" |
| | | #include "bh_api.h" |
| | | #include <pthread.h> |
| | |
| | | static Logger *logger = LoggerFactory::getLogger(); |
| | | |
| | | static int gRun_stat = 0; |
| | | static int gRun_flag = true; |
| | | static void *gNetmod_socket = NULL; |
| | | |
| | | static pthread_mutex_t mutex; |
| | |
| | | nsec = 0; |
| | | sprintf(buf, "%s", STR_EXEC); |
| | | data = net_mod_socket_int_get(gNetmod_socket); |
| | | while(true) { |
| | | while(gRun_flag == true) { |
| | | |
| | | rv = net_mod_socket_recvfrom(gNetmod_socket, &buf_temp, &size, &key, SVR_STR, data); |
| | | if (rv == 0) { |
| | | |
| | | BHFree(buf_temp, size); |
| | | if (strncmp((char *)buf_temp, STR_RET, strlen(STR_RET)) != 0) { |
| | | |
| | | if ((gNetmod_socket != NULL) && (gRun_stat != 0)) { |
| | | rv = net_mod_socket_sendto_timeout(gNetmod_socket, buf, strlen(buf), key, sec, nsec, SVR_STR, data); |
| | | if (rv != 0) { |
| | | logger->error("the process check response failed with error: %s!\n", bus_strerror(rv)); |
| | | } |
| | | } else { |
| | | break; |
| | | gRun_flag = false; |
| | | } |
| | | |
| | | BHFree(buf_temp, size); |
| | | |
| | | } else { |
| | | |
| | |
| | | #endif |
| | | |
| | | if (rv == 0) { |
| | | gRun_flag = true; |
| | | pthread_create(&gTids, NULL, client_run_check, NULL); |
| | | |
| | | return true; |
| | |
| | | { |
| | | int rv; |
| | | int min; |
| | | int data; |
| | | int diff; |
| | | void *buf = NULL; |
| | | char *errString = NULL; |
| | | struct timeval start, end; |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | | struct _ProcInfo_proto |
| | |
| | | if (rv == 0) { |
| | | rv = net_mod_socket_reg(gNetmod_socket, NULL, 0, NULL, 0, timeout_ms, PROC_UNREG); |
| | | if (rv == 0) { |
| | | |
| | | gettimeofday(&start, NULL); |
| | | data = net_mod_socket_int_get(gNetmod_socket); |
| | | rv = net_mod_socket_sendto_timeout(gNetmod_socket, STR_RET, strlen(STR_RET), data, 3, 0); |
| | | if (rv != 0) { |
| | | logger->error("the process check response failed with error: %s!\n", bus_strerror(rv)); |
| | | } |
| | | |
| | | while(gRun_flag == true) { |
| | | sleep(1); |
| | | |
| | | gettimeofday(&end, NULL); |
| | | |
| | | diff = end.tv_sec - start.tv_sec; |
| | | if (diff >= TIME_DUR) |
| | | break; |
| | | }; |
| | | |
| | | net_mod_socket_close(gNetmod_socket); |
| | | |
| | | gNetmod_socket = NULL; |
| | |
| | | char data_buf[MAX_STR_LEN] = { 0x00 }; |
| | | char buf_temp[MAX_STR_LEN] = { 0x00 }; |
| | | char *topics_buf = NULL; |
| | | |
| | | hashtable_t *hashtable = mm_get_hashtable(); |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | | struct _BHAddress |
| | | { |
| | |
| | | #else |
| | | strncpy(buf_temp, (char *)request, (sizeof(buf_temp) - 1) > strlen((char *)request) ? strlen((char *)request) : (sizeof(buf_temp) - 1)); |
| | | #endif |
| | | |
| | | |
| | | str = buf_temp; |
| | | val = net_mod_socket_buf_data_get(gNetmod_socket, str); |
| | | if(val > 0) { |
| | | |
| | | if ((val > 0) && (hashtable_get(hashtable, val) != NULL)) { |
| | | |
| | | rv = 0; |
| | | |
| | | } else { |
| | | |
| | | if ((val > 0) && (hashtable_get(hashtable, val) == NULL)) { |
| | | net_mod_socket_buf_data_del(gNetmod_socket, str); |
| | | } |
| | | |
| | | rv = net_mod_socket_reg(gNetmod_socket, buf_temp, strlen(buf_temp), &buf, &size, timeout_ms, PROC_QUE_STCS); |
| | | if (rv == 0) { |
| | | |
| | |
| | | char *errString = NULL; |
| | | char buf_temp[MAX_STR_LEN] = { 0x00 }; |
| | | char *topics_buf = NULL; |
| | | |
| | | hashtable_t *hashtable = mm_get_hashtable(); |
| | | |
| | | struct _RequestReply |
| | | { |
| | | std::string proc_id; |
| | |
| | | |
| | | str = buf_temp; |
| | | val = net_mod_socket_buf_data_get(gNetmod_socket, str); |
| | | if(val > 0) { |
| | | |
| | | if ((val > 0) && (hashtable_get(hashtable, val) != NULL)) { |
| | | rv = 0; |
| | | |
| | | } else { |
| | | if ((val > 0) && (hashtable_get(hashtable, val) == NULL)) { |
| | | net_mod_socket_buf_data_del(gNetmod_socket, str); |
| | | } |
| | | |
| | | rv = net_mod_socket_reg(gNetmod_socket, buf_temp, strlen(buf_temp), &buf, &size, timeout_ms, PROC_QUE_STCS); |
| | | if (rv == 0) { |
| | | |