| | |
| | | } |
| | | |
| | | /* One-time key creation function */ |
| | | void NetModSocket::_createKey_(void) |
| | | void NetModSocket::_createConnPoolKey_(void) |
| | | { |
| | | int ret; |
| | | |
| | |
| | | NetConnPool *mpool; |
| | | |
| | | /* Make first caller allocate key for thread-specific data */ |
| | | ret = pthread_once(&once, _createKey_); |
| | | ret = pthread_once(&once, _createConnPoolKey_); |
| | | if (ret != 0) { |
| | | LoggerFactory::getLogger()->error(errno, "NetModSocket::_sendandrecv_ pthread_once"); |
| | | exit(1); |
| | |
| | | mpool = (NetConnPool *)pthread_getspecific(poolKey); |
| | | if (mpool == NULL) |
| | | { |
| | | /* If first call from this thread, allocate |
| | | buffer for thread, and save its location */ |
| | | /* If first call from this thread, allocate buffer for thread, and save its location */ |
| | | logger->debug("Create connPool"); |
| | | mpool = new NetConnPool(); |
| | | if (mpool == NULL) { |
| | | LoggerFactory::getLogger()->error(errno, "NetModSocket::_sendandrecv_ malloc"); |
| | |
| | | NetConnPool *mpool; |
| | | |
| | | /* Make first caller allocate key for thread-specific data */ |
| | | ret = pthread_once(&once, _createKey_); |
| | | ret = pthread_once(&once, _createConnPoolKey_); |
| | | if (ret != 0) { |
| | | LoggerFactory::getLogger()->error(errno, "NetModSocket::_sendandrecv_ pthread_once"); |
| | | exit(1); |
| | |
| | | continue; |
| | | } |
| | | request_head.mod = BUS; |
| | | memcpy(request_head.host, node->host, sizeof(request_head.host)); |
| | | request_head.key = node->key; |
| | | request_head.content_length = content_size; |
| | | request_head.topic_length = strlen(topic) + 1; |