| | |
| | | if(topic_sub_map != NULL) { |
| | | for (map_iter = topic_sub_map->begin(); map_iter != topic_sub_map->end(); map_iter++) { |
| | | subscripter_set = map_iter->second; |
| | | delete subscripter_set; |
| | | subscripter_set->clear(); |
| | | mm_free((void *)subscripter_set); |
| | | //delete subscripter_set; |
| | | // printf("=============delete subscripter_set\n"); |
| | | } |
| | | topic_sub_map->clear(); |
| | | mem_pool_free_by_key(BUS_MAP_KEY); |
| | | } |
| | | |
| | | // printf("=============close socket\n"); |
| | | shm_close_socket(socket->shm_socket); |
| | | free(_socket); |
| | | } |
| | |
| | | subscripter_set = map_iter->second; |
| | | for(set_iter = subscripter_set->begin(); set_iter != subscripter_set->end(); set_iter++) { |
| | | send_port = *set_iter; |
| | | printf("_proxy_pub send before %d \n", send_port); |
| | | // printf("_proxy_pub send before %d \n", send_port); |
| | | if (shm_sendto(socket->shm_socket, buf+head_len, size-head_len, send_port, &timeout) !=0 ) { |
| | | //对方已关闭的连接放到待删除队列里。如果直接删除会让iter指针出现错乱 |
| | | subscripter_to_del.push_back(send_port); |
| | | } else { |
| | | printf("_proxy_pub send after: %d \n", send_port); |
| | | // printf("_proxy_pub send after: %d \n", send_port); |
| | | } |
| | | |
| | | |
| | |
| | | size_t head_len; |
| | | |
| | | const char *topic_delim = ","; |
| | | printf("run_pubsub_proxy server receive before\n"); |
| | | // printf("run_pubsub_proxy server receive before\n"); |
| | | while(shm_recvfrom(socket->shm_socket, (void **)&buf, &size, &port) == 0) { |
| | | printf("run_pubsub_proxy server recv after: %s \n", buf); |
| | | // printf("run_pubsub_proxy server recv after: %s \n", buf); |
| | | if(parse_pubsub_topic(buf, size, &action, &topics, &head_len)) { |
| | | if(strcmp(action, "sub") == 0) { |
| | | // 订阅支持多主题订阅 |