From 8f2a5a0b40fc82126c691d5c30131d908772aab7 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 15 Mar 2013 15:30:25 -0700 Subject: Clean up internal libc logging. We only need one logging API, and I prefer the one that does no allocation and is thus safe to use in any context. Also use O_CLOEXEC when opening the /dev/log files. Move everything logging-related into one header file. Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58 --- libc/netbsd/resolv/res_send.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'libc/netbsd/resolv/res_send.c') diff --git a/libc/netbsd/resolv/res_send.c b/libc/netbsd/resolv/res_send.c index f3ee53979..c6c863bfa 100644 --- a/libc/netbsd/resolv/res_send.c +++ b/libc/netbsd/resolv/res_send.c @@ -119,7 +119,7 @@ __RCSID("$NetBSD: res_send.c,v 1.9 2006/01/24 17:41:25 christos Exp $"); # include #endif -#include "logd.h" +#include "libc_logging.h" #ifndef DE_CONST #define DE_CONST(c,v) v = ((c) ? \ @@ -542,7 +542,7 @@ res_nsend(res_state statp, ns); if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", + __libc_format_log(ANDROID_LOG_DEBUG, "libc", "used send_vc %d\n", n); } @@ -554,15 +554,13 @@ res_nsend(res_state statp, } else { /* Use datagrams. */ if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", - "using send_dg\n"); + __libc_format_log(ANDROID_LOG_DEBUG, "libc", "using send_dg\n"); } n = send_dg(statp, buf, buflen, ans, anssiz, &terrno, ns, &v_circuit, &gotsomewhere); if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", - "used send_dg %d\n",n); + __libc_format_log(ANDROID_LOG_DEBUG, "libc", "used send_dg %d\n",n); } if (n < 0) @@ -570,7 +568,7 @@ res_nsend(res_state statp, if (n == 0) goto next_ns; if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", + __libc_format_log(ANDROID_LOG_DEBUG, "libc", "time=%d, %d\n",time(NULL), time(NULL)%2); } if (v_circuit) @@ -715,8 +713,7 @@ static int get_timeout(const res_state statp, const int ns) timeout = 1; } if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", - "using timeout of %d sec\n", timeout); + __libc_format_log(ANDROID_LOG_DEBUG, "libc", "using timeout of %d sec\n", timeout); } return timeout; @@ -738,7 +735,7 @@ send_vc(res_state statp, void *tmp; if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", "using send_vc\n"); + __libc_format_log(ANDROID_LOG_DEBUG, "libc", "using send_vc\n"); } nsap = get_nsaddr(statp, (size_t)ns); @@ -939,8 +936,7 @@ connect_with_timeout(int sock, const struct sockaddr *nsap, socklen_t salen, int timeout = evConsTime((long)sec, 0L); finish = evAddTime(now, timeout); if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", - " %d send_vc\n", sock); + __libc_format_log(ANDROID_LOG_DEBUG, "libc", " %d send_vc\n", sock); } res = retrying_select(sock, &rset, &wset, &finish); @@ -951,7 +947,7 @@ connect_with_timeout(int sock, const struct sockaddr *nsap, socklen_t salen, int done: fcntl(sock, F_SETFL, origflags); if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", + __libc_format_log(ANDROID_LOG_DEBUG, "libc", " %d connect_with_timeout returning %s\n", sock, res); } return res; @@ -967,7 +963,7 @@ retrying_select(const int sock, fd_set *readset, fd_set *writeset, const struct retry: if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", " %d retying_select\n", sock); + __libc_format_log(ANDROID_LOG_DEBUG, "libc", " %d retying_select\n", sock); } now = evNowTime(); @@ -987,7 +983,7 @@ retry: n = pselect(sock + 1, readset, writeset, NULL, &timeout, NULL); if (n == 0) { if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, " libc", + __libc_format_log(ANDROID_LOG_DEBUG, " libc", " %d retrying_select timeout\n", sock); } errno = ETIMEDOUT; @@ -997,7 +993,7 @@ retry: if (errno == EINTR) goto retry; if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", + __libc_format_log(ANDROID_LOG_DEBUG, "libc", " %d retrying_select got error %d\n",sock, n); } return n; @@ -1007,7 +1003,7 @@ retry: if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &error, &len) < 0 || error) { errno = error; if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", + __libc_format_log(ANDROID_LOG_DEBUG, "libc", " %d retrying_select dot error2 %d\n", sock, errno); } @@ -1015,7 +1011,7 @@ retry: } } if (DBG) { - __libc_android_log_print(ANDROID_LOG_DEBUG, "libc", + __libc_format_log(ANDROID_LOG_DEBUG, "libc", " %d retrying_select returning %d for %d\n",sock, n); } -- cgit v1.2.3