| | |
| | | logger->debug("shm_open_socket\n"); |
| | | shm_socket_t *socket = (shm_socket_t *)calloc(1, sizeof(shm_socket_t)); |
| | | socket->socket_type = socket_type; |
| | | socket->key = -1; |
| | | socket->key = 0; |
| | | socket->force_bind = false; |
| | | socket->dispatch_thread = 0; |
| | | socket->status = SHM_CONN_CLOSED; |
| | |
| | | |
| | | int key; |
| | | hashtable_t *hashtable = mm_get_hashtable(); |
| | | if (socket->key == -1) { |
| | | if (socket->key == 0) { |
| | | key = hashtable_alloc_key(hashtable); |
| | | socket->key = key; |
| | | } else { |
| | |
| | | return -1; |
| | | } |
| | | |
| | | if (socket->key == -1) { |
| | | if (socket->key == 0) { |
| | | socket->key = hashtable_alloc_key(hashtable); |
| | | } else { |
| | | if(!_shm_socket_check_key(socket)) { |
| | |
| | | err_exit(s, "shm_sendto : pthread_mutex_lock"); |
| | | |
| | | if (socket->queue == NULL) { |
| | | if (socket->key == -1) { |
| | | if (socket->key == 0) { |
| | | socket->key = hashtable_alloc_key(hashtable); |
| | | } else { |
| | | |
| | |
| | | delete remoteQueue; |
| | | mm_free(dest.buf); |
| | | if(rv == EBUS_TIMEOUT) { |
| | | bus_errno = EBUS_TIMEOUT; |
| | | logger->error(errno, "sendto key %d failed, %s", key, bus_strerror(EBUS_TIMEOUT)); |
| | | // bus_errno = EBUS_TIMEOUT; |
| | | // logger->error("sendto key %d failed, %s", key, bus_strerror(EBUS_TIMEOUT)); |
| | | return EBUS_TIMEOUT; |
| | | } else { |
| | | //logger->error(errno, "sendto key %d failed!", key); |
| | | return -1; |
| | | return rv; |
| | | } |
| | | |
| | | |
| | |
| | | err_exit(s, "shm_recvfrom : pthread_mutex_lock"); |
| | | |
| | | if (socket->queue == NULL) { |
| | | if (socket->key == -1) { |
| | | if (socket->key == 0) { |
| | | socket->key = hashtable_alloc_key(hashtable); |
| | | } else { |
| | | |
| | |
| | | mm_free(src.buf); |
| | | return 0; |
| | | } else { |
| | | return -1; |
| | | |
| | | if(rv == EBUS_TIMEOUT) { |
| | | // logger->error("shm_recvfrom failed, %s", bus_strerror(EBUS_TIMEOUT)); |
| | | return EBUS_TIMEOUT; |
| | | } else { |
| | | // logger->error(rv, "shm_recvfrom failed!"); |
| | | return rv; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |