Update code

This commit is contained in:
Nick Peng
2018-07-02 23:31:39 +08:00
parent 4490b318bd
commit 593a091255
3 changed files with 42 additions and 30 deletions

View File

@@ -1228,6 +1228,9 @@ static int _dns_decode_opt_ecs(struct dns_context *context, struct dns_opt_ecs *
memcpy(ecs->addr, context->ptr, len); memcpy(ecs->addr, context->ptr, len);
context->ptr += len; context->ptr += len;
tlog(TLOG_DEBUG, "ECS: family:%d, source_prefix:%d, scope_prefix:%d, len:%d", ecs->family, ecs->source_prefix, ecs->scope_prefix, len);
tlog(TLOG_DEBUG, "%d.%d.%d.%d", ecs->addr[0], ecs->addr[1], ecs->addr[2], ecs->addr[3]);
return 0; return 0;
} }
@@ -1283,9 +1286,11 @@ static int _dns_decode_opt(struct dns_context *context, dns_rr_type type, unsign
} }
ever = ever; ever = ever;
tlog(TLOG_DEBUG, "decode opt.");
while (context->ptr - start < rr_len) { while (context->ptr - start < rr_len) {
opt_code = dns_read_short(&context->ptr); opt_code = dns_read_short(&context->ptr);
opt_len = dns_read_short(&context->ptr); opt_len = dns_read_short(&context->ptr);
tlog(TLOG_DEBUG, "opt type %d", opt_code);
switch (opt_code) { switch (opt_code) {
case DNS_OPT_T_ECS: { case DNS_OPT_T_ECS: {
struct dns_opt_ecs ecs; struct dns_opt_ecs ecs;

View File

@@ -1,5 +1,7 @@
/* /*
* ttinylog
* Copyright (C) 2018 Ruilin Peng (Nick) <pymumu@gmail.com> * Copyright (C) 2018 Ruilin Peng (Nick) <pymumu@gmail.com>
* https://github.com/pymumu/tinylog
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
#include "tlog.h" #include "tlog.h"
@@ -591,6 +593,7 @@ static void _tlog_close_all_fd(void)
char path_name[PATH_MAX]; char path_name[PATH_MAX];
DIR *dir = NULL; DIR *dir = NULL;
struct dirent *ent; struct dirent *ent;
int dir_fd = -1;
snprintf(path_name, sizeof(path_name), "/proc/self/fd/"); snprintf(path_name, sizeof(path_name), "/proc/self/fd/");
dir = opendir(path_name); dir = opendir(path_name);
@@ -599,9 +602,11 @@ static void _tlog_close_all_fd(void)
goto errout; goto errout;
} }
dir_fd = dirfd(dir);
while ((ent = readdir(dir)) != NULL) { while ((ent = readdir(dir)) != NULL) {
int fd = atoi(ent->d_name); int fd = atoi(ent->d_name);
if (fd < 0 || dirfd(dir) == fd) { if (fd < 0 || dir_fd == fd) {
continue; continue;
} }
switch (fd) { switch (fd) {

View File

@@ -1,5 +1,7 @@
/* /*
* tinylog
* Copyright (C) 2018 Ruilin Peng (Nick) <pymumu@gmail.com> * Copyright (C) 2018 Ruilin Peng (Nick) <pymumu@gmail.com>
* https://github.com/pymumu/tinylog
*/ */
#ifndef TLOG_H #ifndef TLOG_H