/* Set to 1 to enable debug traces */ #define DEBUG 0
#if DEBUG # include <async_safe/log.h> # include <unistd.h> /* for gettid() */ # define D(...) async_safe_format_log(ANDROID_LOG_DEBUG,"libc", __VA_ARGS__) #else # define D(...) do{}while(0) #endif
typedefstruct { int _h_errno; // TODO: Have one __res_state per network so we don't have to repopulate frequently. struct __res_state _nres[1]; struct res_static _rstatic[1];
} _res_thread;
staticvoid
_res_static_done(struct res_static* rs)
{ /* fortunately, there is nothing to do here, since the *pointsinh_addr_ptrsandhost_aliasesshouldall *pointto'hostbuf'
*/ if (rs->hostf) { /* should not happen in theory, but just be safe */
fclose(rs->hostf);
rs->hostf = NULL;
}
free(rs->servent.s_aliases);
}
/* It is the first time this function is called in this thread,
* we need to create a new thread-specific DNS resolver state. */
rt = _res_thread_alloc(); if (rt == NULL) { return NULL;
}
pthread_setspecific( _res_key, rt );
D("%s: tid=%d Created new DNS state rt=%p",
__FUNCTION__, gettid(), rt);
/* Reset the state, note that res_ninit() can now properly reset *anexistingstatewithoutleakingmemory.
*/
D("%s: tid=%d, rt=%p, setting DNS state (options RES_INIT=%d)",
__FUNCTION__, gettid(), rt, (rt->_nres->options & RES_INIT) != 0); if ( res_ninit( rt->_nres ) < 0 ) { /* This should not happen */
D("%s: tid=%d rt=%p, woot, res_ninit() returned < 0",
__FUNCTION__, gettid(), rt);
_res_thread_free(rt);
pthread_setspecific( _res_key, NULL ); return NULL;
} return rt;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.