| | |
| | | |
| | | NetModSocket::NetModSocket() |
| | | { |
| | | if (Signal(SIGPIPE, SIG_IGN) == SIG_ERR) err_msg(errno, "signal"); |
| | | if (Signal(SIGPIPE, SIG_IGN) == SIG_ERR) |
| | | logger->error(errno, "NetModSocket::NetModSocket signal"); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /* Free thread-specific data buffer */ |
| | | void NetModSocket::_destructor_(void *_pool) |
| | | void NetModSocket::_destroyConnPool_(void *_pool) |
| | | { |
| | | |
| | | NetConnPool *mpool = (NetConnPool *)_pool; |
| | | delete mpool; |
| | | logger->debug("destory connPool"); |
| | | } |
| | | |
| | | /* One-time key creation function */ |
| | |
| | | /* Allocate a unique thread-specific data key and save the address |
| | | of the destructor for thread-specific data buffers */ |
| | | |
| | | ret = pthread_key_create(&poolKey, _destructor_); |
| | | ret = pthread_key_create(&poolKey, _destroyConnPool_); |
| | | if (ret != 0) { |
| | | logger->error(ret, "pthread_key_create"); |
| | | exit(1); |
| | |
| | | int i, n, recv_size, connfd; |
| | | net_node_t *node; |
| | | void *recv_buf; |
| | | |
| | | |
| | | |
| | | net_mod_request_head_t request_head = {}; |
| | | |
| | |
| | | NetConnPool *mpool; |
| | | |
| | | /* Make first caller allocate key for thread-specific data */ |
| | | |
| | | ret = pthread_once(&once, _createKey_); |
| | | if (ret != 0) { |
| | | LoggerFactory::getLogger()->error(errno, "NetModSocket::_sendandrecv_ pthread_once"); |