| | |
| | | } |
| | | |
| | | shm_msg_t src; |
| | | //logger.debug("shm_recvfrom pop before"); |
| | | // printf("shm_recvfrom pop before"); |
| | | if (socket->queue->pop(src)) { |
| | | void * _buf = malloc(src.size); |
| | | memcpy(_buf, src.buf, src.size); |
| | |
| | | *size = src.size; |
| | | *port = src.port; |
| | | mm_free(src.buf); |
| | | //logger.debug("shm_recvfrom pop after"); |
| | | // printf("shm_recvfrom pop after"); |
| | | return 0; |
| | | } else { |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | int shm_sendandrecv(shm_socket_t *socket, const void *send_buf, const int send_size, const int send_port, void **recv_buf, int *recv_size) { |
| | | int recv_port; |
| | | int rv; |
| | | |
| | | shm_socket_t *tmp_socket = shm_open_socket(SHM_SOCKET_DGRAM); |
| | | if (shm_sendto(tmp_socket, send_buf, send_size, send_port) == 0) { |
| | | rv = shm_recvfrom(tmp_socket, recv_buf, recv_size, &recv_port); |
| | | shm_close_socket(tmp_socket); |
| | | return rv; |
| | | } |
| | | return -1; |
| | | } |
| | | |
| | | |
| | |
| | | if( iter != socket->clientSocketMap->end() ) { |
| | | socket->clientSocketMap->erase(iter); |
| | | } |
| | | //free((void *)client_socket); |
| | | free((void *)client_socket); |
| | | |
| | | } |
| | | |