MDnsSdListener::Monitor::Monitor() {
mHead = NULL;
- pthread_mutex_init(&mHeadMutex, NULL);
+ mLiveCount = 0;
+ mPollFds = NULL;
+ mPollRefs = NULL;
+ mPollSize = 10;
socketpair(AF_LOCAL, SOCK_STREAM, 0, mCtrlSocketPair);
+ pthread_mutex_init(&mHeadMutex, NULL);
+
pthread_create(&mThread, NULL, MDnsSdListener::Monitor::threadStart, this);
pthread_detach(mThread);
}
void MDnsSdListener::Monitor::run() {
int pollCount = 1;
- mPollSize = 10;
mPollFds = (struct pollfd *)calloc(sizeof(struct pollfd), mPollSize);
mPollRefs = (DNSServiceRef **)calloc(sizeof(DNSServiceRef *), mPollSize);
+ LOG_ALWAYS_FATAL_IF((mPollFds == NULL), "initial calloc failed on mPollFds with a size of %d",
+ ((int)sizeof(struct pollfd)) * mPollSize);
+ LOG_ALWAYS_FATAL_IF((mPollRefs == NULL), "initial calloc failed on mPollRefs with a size of %d",
+ ((int)sizeof(DNSServiceRef *)) * mPollSize);
mPollFds[0].fd = mCtrlSocketPair[0];
mPollFds[0].events = POLLIN;
free(mPollRefs);
mPollFds = (struct pollfd *)calloc(sizeof(struct pollfd), mPollSize);
mPollRefs = (DNSServiceRef **)calloc(sizeof(DNSServiceRef *), mPollSize);
+ LOG_ALWAYS_FATAL_IF((mPollFds == NULL), "calloc failed on mPollFds with a size of %d",
+ ((int)sizeof(struct pollfd)) * mPollSize);
+ LOG_ALWAYS_FATAL_IF((mPollRefs == NULL), "calloc failed on mPollRefs with a size of %d",
+ ((int)sizeof(DNSServiceRef *)) * mPollSize);
} else {
memset(mPollFds, 0, sizeof(struct pollfd) * mPollSize);
memset(mPollRefs, 0, sizeof(DNSServiceRef *) * mPollSize);