diff --git a/package/linux/make.sh b/package/linux/make.sh old mode 100644 new mode 100755 diff --git a/src/dns_client.c b/src/dns_client.c index a4fa36b..6c01530 100644 --- a/src/dns_client.c +++ b/src/dns_client.c @@ -1774,10 +1774,10 @@ static int _DNS_client_create_socket_tls(struct dns_server_info *server_info, ch } // ? this cause ssl crash ? - // setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes)); - // setsockopt(fd, IPPROTO_TCP, TCP_THIN_DUPACK, &yes, sizeof(yes)); - // setsockopt(fd, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS, &yes, sizeof(yes)); - // set_sock_keepalive(fd, 15, 3, 4); + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes)); + setsockopt(fd, IPPROTO_TCP, TCP_THIN_DUPACK, &yes, sizeof(yes)); + setsockopt(fd, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS, &yes, sizeof(yes)); + set_sock_keepalive(fd, 15, 3, 4); setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &priority, sizeof(priority)); setsockopt(fd, IPPROTO_IP, IP_TOS, &ip_tos, sizeof(ip_tos)); diff --git a/src/fast_ping.c b/src/fast_ping.c index 54352bc..0f2781e 100644 --- a/src/fast_ping.c +++ b/src/fast_ping.c @@ -365,7 +365,12 @@ static void _fast_ping_close_host_sock(struct ping_host_struct *ping_host) static void _fast_ping_host_put(struct ping_host_struct *ping_host) { - if (!atomic_dec_and_test(&ping_host->ref)) { + int ref_cnt = atomic_dec_and_test(&ping_host->ref); + if (!ref_cnt) { + if (ref_cnt < 0) { + tlog(TLOG_ERROR, "invalid refcount of ping_host %s", ping_host->host); + abort(); + } return; } @@ -1081,15 +1086,19 @@ struct ping_host_struct *fast_ping_start(PING_TYPE type, const char *host, int c pthread_mutex_unlock(&ping.map_lock); _fast_ping_host_get(ping_host); + _fast_ping_host_get(ping_host); + // for ping race condition, get reference count twice if (_fast_ping_sendping(ping_host) != 0) { goto errout_remove; } ping_host->run = 1; freeaddrinfo(gai); + _fast_ping_host_put(ping_host); return ping_host; errout_remove: fast_ping_stop(ping_host); + _fast_ping_host_put(ping_host); ping_host = NULL; errout: if (gai) { diff --git a/src/util.c b/src/util.c index e1fa339..fcc7289 100644 --- a/src/util.c +++ b/src/util.c @@ -1045,7 +1045,7 @@ void print_stack(void) } tlog(TLOG_FATAL, "Stack:"); - for (size_t idx = 0; idx < frame_num; ++idx) { + for (int idx = 0; idx < frame_num; ++idx) { const void *addr = buffer[idx]; const char *symbol = "";