Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93d0afd1 authored by Hungming Chen's avatar Hungming Chen
Browse files

Remove thread-local variable h_errno in resolver state

libnetd_resolv doesn't use thread-local variable h_errno to return error
code anymore and uses an int pointer instead.

Test: built, flashed, booted
      system/netd/tests/runtests.sh pass

Change-Id: I96b2707de448a598751238abc508da3464dec338
parent 6c84a3d0
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@
#include "resolv_private.h"

typedef struct {
    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];
@@ -53,7 +52,6 @@ static _res_thread* res_thread_alloc(void) {
    _res_thread* rt = (_res_thread*) calloc(1, sizeof(*rt));

    if (rt) {
        rt->_h_errno = 0;
        memset(rt->_rstatic, 0, sizeof rt->_rstatic);
    }
    return rt;
@@ -119,13 +117,6 @@ static _res_thread* res_thread_get(void) {

struct __res_state _nres;

int* __get_h_errno(void) {
    _res_thread* rt = res_thread_get();
    static int panic = NETDB_INTERNAL;

    return rt ? &rt->_h_errno : &panic;
}

res_state res_get_state(void) {
    _res_thread* rt = res_thread_get();

+0 −22
Original line number Diff line number Diff line
@@ -70,27 +70,6 @@
#endif
#define MAXHOSTNAMELEN 256

/*
 * This used to be defined in res_query.c, now it's in herror.c.
 * [XXX no it's not.  It's in irs/irs_data.c]
 * It was
 * never extern'd by any *.h file before it was placed here.  For thread
 * aware programs, the last h_errno value set is stored in res->h_errno.
 *
 * XXX:	There doesn't seem to be a good reason for exposing RES_SET_H_ERRNO
 *	(and __h_errno_set) to the public via <resolv.h>.
 * XXX:	__h_errno_set is really part of IRS, not part of the resolver.
 *	If somebody wants to build and use a resolver that doesn't use IRS,
 *	what do they do?  Perhaps something like
 *		#ifdef WANT_IRS
 *		# define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
 *		#else
 *		# define RES_SET_H_ERRNO(r,x) (h_errno = (r)->res_h_errno = (x))
 *		#endif
 */

#define RES_SET_H_ERRNO(r, x) (h_errno = (r)->res_h_errno = (x))

/*
 * Global defines and variables for resolver stub.
 */
@@ -126,7 +105,6 @@ struct __res_state {
        struct in_addr addr;
        uint32_t mask;
    } sort_list[MAXRESOLVSORT];
    int res_h_errno;      /* last one set for this context */
    unsigned _mark;       /* If non-0 SET_MARK to _mark on all request sockets */
    int _vcsock;          /* PRIVATE: for res_send VC i/o */
    u_int _flags;         /* PRIVATE: see below */