From 7d5512682b3abaa917bd9d7414d3da88897d83b7 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Sun, 27 Sep 2020 08:53:57 +0800 Subject: [PATCH] fixed printf format for port --- HISTORY | 2 +- src/connection_pool.c | 20 ++++++++++---------- src/http_func.c | 12 ++++++------ src/multi_socket_client.c | 20 ++++++++++---------- src/server_id_func.c | 10 +++++----- src/sockopt.c | 2 +- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/HISTORY b/HISTORY index fe1bd16..0e2cd87 100644 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,5 @@ -Version 1.44 2020-09-25 +Version 1.44 2020-09-27 * add test file src/tests/test_pthread_lock.c * add uniq_skiplist.[hc] * add function split_string_ex diff --git a/src/connection_pool.c b/src/connection_pool.c index 694894d..2a41ce3 100644 --- a/src/connection_pool.c +++ b/src/connection_pool.c @@ -129,7 +129,7 @@ int conn_pool_connect_server_ex(ConnectionInfo *conn, if (log_connect_error) { logError("file: "__FILE__", line: %d, " - "connect to server %s:%d fail, errno: %d, " + "connect to server %s:%u fail, errno: %d, " "error info: %s", __LINE__, conn->ip_addr, conn->port, result, STRERROR(result)); } @@ -163,7 +163,7 @@ int conn_pool_async_connect_server_ex(ConnectionInfo *conn, if (!(result == 0 || result == EINPROGRESS)) { logError("file: "__FILE__", line: %d, " - "connect to server %s:%d fail, errno: %d, " + "connect to server %s:%u fail, errno: %d, " "error info: %s", __LINE__, conn->ip_addr, conn->port, result, STRERROR(result)); close(conn->sock); @@ -229,7 +229,7 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp, { *err_no = ENOSPC; logError("file: "__FILE__", line: %d, " \ - "connections: %d of server %s:%d " \ + "connections: %d of server %s:%u " \ "exceed limit: %d", __LINE__, \ cm->total_count, conn->ip_addr, \ conn->port, cp->max_count_per_entry); @@ -284,7 +284,7 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp, } logDebug("file: "__FILE__", line: %d, " \ - "server %s:%d, new connection: %d, " \ + "server %s:%u, new connection: %d, " \ "total_count: %d, free_count: %d", \ __LINE__, conn->ip_addr, conn->port, \ node->conn->sock, cm->total_count, \ @@ -332,7 +332,7 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp, cm->total_count--; logDebug("file: "__FILE__", line: %d, " \ - "server %s:%d, connection: %d idle " \ + "server %s:%u, connection: %d idle " \ "time: %d exceeds max idle time: %d, "\ "total_count: %d, free_count: %d", \ __LINE__, conn->ip_addr, conn->port, \ @@ -348,7 +348,7 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp, pthread_mutex_unlock(&cm->lock); logDebug("file: "__FILE__", line: %d, " \ - "server %s:%d, reuse connection: %d, " \ + "server %s:%u, reuse connection: %d, " \ "total_count: %d, free_count: %d", __LINE__, conn->ip_addr, conn->port, ci->sock, cm->total_count, cm->free_count); @@ -374,7 +374,7 @@ int conn_pool_close_connection_ex(ConnectionPool *cp, ConnectionInfo *conn, if (cm == NULL) { logError("file: "__FILE__", line: %d, " \ - "hash entry of server %s:%d not exist", __LINE__, \ + "hash entry of server %s:%u not exist", __LINE__, \ conn->ip_addr, conn->port); return ENOENT; } @@ -383,7 +383,7 @@ int conn_pool_close_connection_ex(ConnectionPool *cp, ConnectionInfo *conn, if (node->manager != cm) { logError("file: "__FILE__", line: %d, " \ - "manager of server entry %s:%d is invalid!", \ + "manager of server entry %s:%u is invalid!", \ __LINE__, conn->ip_addr, conn->port); return EINVAL; } @@ -394,7 +394,7 @@ int conn_pool_close_connection_ex(ConnectionPool *cp, ConnectionInfo *conn, cm->total_count--; logDebug("file: "__FILE__", line: %d, " - "server %s:%d, release connection: %d, " + "server %s:%u, release connection: %d, " "total_count: %d, free_count: %d", __LINE__, conn->ip_addr, conn->port, conn->sock, cm->total_count, cm->free_count); @@ -417,7 +417,7 @@ int conn_pool_close_connection_ex(ConnectionPool *cp, ConnectionInfo *conn, cm->free_count++; logDebug("file: "__FILE__", line: %d, " \ - "server %s:%d, free connection: %d, " \ + "server %s:%u, free connection: %d, " \ "total_count: %d, free_count: %d", __LINE__, conn->ip_addr, conn->port, conn->sock, cm->total_count, cm->free_count); diff --git a/src/http_func.c b/src/http_func.c index 9d29784..071881f 100644 --- a/src/http_func.c +++ b/src/http_func.c @@ -131,7 +131,7 @@ int get_url_content_ex(const char *url, const int url_len, close(sock); sprintf(error_info, "file: "__FILE__", line: %d, " \ - "connect to %s:%d fail, errno: %d, " \ + "connect to %s:%u fail, errno: %d, " \ "error info: %s", __LINE__, domain_name, \ port, result, STRERROR(result)); @@ -140,7 +140,7 @@ int get_url_content_ex(const char *url, const int url_len, out_len = snprintf(out_buff, sizeof(out_buff), \ "GET %s HTTP/1.0\r\n" \ - "Host: %s:%d\r\n" \ + "Host: %s:%u\r\n" \ "Connection: close\r\n" \ "\r\n", pURI, domain_name, port); if ((result=tcpsenddata(sock, out_buff, out_len, network_timeout)) != 0) @@ -148,7 +148,7 @@ int get_url_content_ex(const char *url, const int url_len, close(sock); sprintf(error_info, "file: "__FILE__", line: %d, " \ - "send data to %s:%d fail, errno: %d, " \ + "send data to %s:%u fail, errno: %d, " \ "error info: %s", __LINE__, domain_name, \ port, result, STRERROR(result)); @@ -206,7 +206,7 @@ int get_url_content_ex(const char *url, const int url_len, } else { sprintf(error_info, "file: "__FILE__", line: %d, " \ - "recv data from %s:%d fail, errno: %d, " \ + "recv data from %s:%u fail, errno: %d, " \ "error info: %s", __LINE__, domain_name, \ port, result, STRERROR(result)); @@ -218,7 +218,7 @@ int get_url_content_ex(const char *url, const int url_len, if (pContent == NULL) { sprintf(error_info, "file: "__FILE__", line: %d, " \ - "response data from %s:%d is invalid", \ + "response data from %s:%u is invalid", \ __LINE__, domain_name, port); result = EINVAL; @@ -230,7 +230,7 @@ int get_url_content_ex(const char *url, const int url_len, if (pSpace == NULL || pSpace >= pContent) { sprintf(error_info, "file: "__FILE__", line: %d, " \ - "response data from %s:%d is invalid", \ + "response data from %s:%u is invalid", \ __LINE__, domain_name, port); result = EINVAL; diff --git a/src/multi_socket_client.c b/src/multi_socket_client.c index 61fa9bf..90cd7eb 100644 --- a/src/multi_socket_client.c +++ b/src/multi_socket_client.c @@ -124,14 +124,14 @@ static int fast_multi_sock_client_do_send(FastMultiSockClient *client, break; } else if (errno == EINTR) { //should retry logDebug("file: "__FILE__", line: %d, " - "server: %s:%d, ignore interupt signal", + "server: %s:%u, ignore interupt signal", __LINE__, entry->conn->ip_addr, entry->conn->port); continue; } else { result = errno != 0 ? errno : ECONNRESET; logError("file: "__FILE__", line: %d, " - "send to server %s:%d fail, " + "send to server %s:%u fail, " "errno: %d, error info: %s", __LINE__, entry->conn->ip_addr, entry->conn->port, @@ -141,7 +141,7 @@ static int fast_multi_sock_client_do_send(FastMultiSockClient *client, } } else if (bytes == 0) { logError("file: "__FILE__", line: %d, " - "send to server %s:%d, sock: %d fail, " + "send to server %s:%u, sock: %d fail, " "connection disconnected", __LINE__, entry->conn->ip_addr, entry->conn->port, entry->conn->sock); @@ -187,7 +187,7 @@ static int fast_multi_sock_client_send_data(FastMultiSockClient *client, client->entries[i].error_no = ENOTCONN; client->entries[i].done = true; logError("file: "__FILE__", line: %d, " - "NOT connected to %s:%d", + "NOT connected to %s:%u", __LINE__, client->entries[i].conn->ip_addr, client->entries[i].conn->port); continue; @@ -239,14 +239,14 @@ static int fast_multi_sock_client_do_recv(FastMultiSockClient *client, break; } else if (errno == EINTR) { //should retry logDebug("file: "__FILE__", line: %d, " - "server: %s:%d, ignore interupt signal", + "server: %s:%u, ignore interupt signal", __LINE__, entry->conn->ip_addr, entry->conn->port); continue; } else { result = errno != 0 ? errno : ECONNRESET; logError("file: "__FILE__", line: %d, " - "server: %s:%d, recv failed, " + "server: %s:%u, recv failed, " "errno: %d, error info: %s", __LINE__, entry->conn->ip_addr, entry->conn->port, @@ -256,7 +256,7 @@ static int fast_multi_sock_client_do_recv(FastMultiSockClient *client, } } else if (bytes == 0) { logError("file: "__FILE__", line: %d, " - "server: %s:%d, sock: %d, recv failed, " + "server: %s:%u, sock: %d, recv failed, " "connection disconnected", __LINE__, entry->conn->ip_addr, entry->conn->port, entry->conn->sock); @@ -274,7 +274,7 @@ static int fast_multi_sock_client_do_recv(FastMultiSockClient *client, body_length = client->get_body_length_func(&entry->recv_buffer); if (body_length < 0) { logError("file: "__FILE__", line: %d, " - "server: %s:%d, body_length: %d < 0", + "server: %s:%u, body_length: %d < 0", __LINE__, entry->conn->ip_addr, entry->conn->port, body_length); result = EPIPE; @@ -322,7 +322,7 @@ static int fast_multi_sock_client_deal_io(FastMultiSockClient *client) if (event & IOEVENT_ERROR) { logError("file: "__FILE__", line: %d, " - "server: %s:%d, recv error event: %d, " + "server: %s:%u, recv error event: %d, " "connection reset", __LINE__, entry->conn->ip_addr, entry->conn->port, event); @@ -351,7 +351,7 @@ static int fast_multi_sock_client_deal_io(FastMultiSockClient *client) fast_multi_sock_client_finish(client, client->entries + i, ETIMEDOUT); logError("file: "__FILE__", line: %d, " - "recv from %s:%d timedout", + "recv from %s:%u timedout", __LINE__, client->entries[i].conn->ip_addr, client->entries[i].conn->port); } diff --git a/src/server_id_func.c b/src/server_id_func.c index aea0562..02fdea0 100644 --- a/src/server_id_func.c +++ b/src/server_id_func.c @@ -244,7 +244,7 @@ static int fc_server_check_ip_port(FCServerConfig *ctx, id2 = previous->server->id; } logError("file: "__FILE__", line: %d, " - "config file: %s, duplicate ip:port %s:%d, " + "config file: %s, duplicate ip:port %s:%u, " "the server ids: %d, %d", __LINE__, config_filename, previous->ip_addr.str, previous->port, id1, id2); @@ -610,7 +610,7 @@ static int check_addresses_duplicate(FCServerConfig *ctx, if (fc_server_cmp_address_ptr(ppaddr, pprevious) == 0) { logError("file: "__FILE__", line: %d, " "config filename: %s, section: %s, group: %.*s, " - "duplicate ip and port: %s:%d", __LINE__, + "duplicate ip and port: %s:%u", __LINE__, config_filename, section_name, group_addr->server_group->group_name.len, group_addr->server_group->group_name.str, @@ -853,7 +853,7 @@ static int fc_server_set_host(FCServerConfig *ctx, FCServerInfo *server, if (!ctx->share_between_groups && (count > 1 && addr->conn.port > 0)) { logError("file: "__FILE__", line: %d, " "config filename: %s, section: %s, " - "host %s:%d belongs to %d groups", + "host %s:%u belongs to %d groups", __LINE__, config_filename, section_name, addr->conn.ip_addr, addr->conn.port, count); return EEXIST; @@ -1324,7 +1324,7 @@ static void fc_group_servers_to_string(FCServerConfig *ctx, gaddr->server_group->group_name.str, SERVER_ITEM_HOST_AFFIX_STR); } - fast_buffer_append(buffer, " = %s:%d\n", + fast_buffer_append(buffer, " = %s:%u\n", (*addr)->conn.ip_addr, (*addr)->conn.port); } } @@ -1407,7 +1407,7 @@ static void fc_server_log_group_servers(FCGroupAddresses *gaddr) end = gaddr->address_array.addrs + gaddr->address_array.count; for (addr=gaddr->address_array.addrs; addraddress_array.addrs + 1), + logInfo(" %d. %s:%u", (int)(addr - gaddr->address_array.addrs + 1), (*addr)->conn.ip_addr, (*addr)->conn.port); } } diff --git a/src/sockopt.c b/src/sockopt.c index 08a3c0c..7ed2368 100644 --- a/src/sockopt.c +++ b/src/sockopt.c @@ -720,7 +720,7 @@ int socketClientEx2(int af, const char *server_ip, if (*err_no != 0) { logError("file: "__FILE__", line: %d, " - "connect to %s:%d fail, " + "connect to %s:%u fail, " "errno: %d, error info: %s", __LINE__, server_ip, server_port, *err_no, STRERROR(*err_no)); -- GitLab