| | |
| | | #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); |
| | | |
| | |
| | | str = buf_temp; |
| | | val = net_mod_socket_buf_data_get(gNetmod_socket, str); |
| | | if(val > 0) { |
| | | |
| | | rv = 0; |
| | | |
| | | } else { |