fixed printf format for port

pull/37/head
YuQing 2020-09-27 08:53:57 +08:00
parent 082a322f3d
commit 7d5512682b
6 changed files with 33 additions and 33 deletions

View File

@ -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 test file src/tests/test_pthread_lock.c
* add uniq_skiplist.[hc] * add uniq_skiplist.[hc]
* add function split_string_ex * add function split_string_ex

View File

@ -129,7 +129,7 @@ int conn_pool_connect_server_ex(ConnectionInfo *conn,
if (log_connect_error) if (log_connect_error)
{ {
logError("file: "__FILE__", line: %d, " 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, "error info: %s", __LINE__, conn->ip_addr,
conn->port, result, STRERROR(result)); conn->port, result, STRERROR(result));
} }
@ -163,7 +163,7 @@ int conn_pool_async_connect_server_ex(ConnectionInfo *conn,
if (!(result == 0 || result == EINPROGRESS)) if (!(result == 0 || result == EINPROGRESS))
{ {
logError("file: "__FILE__", line: %d, " 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, "error info: %s", __LINE__, conn->ip_addr,
conn->port, result, STRERROR(result)); conn->port, result, STRERROR(result));
close(conn->sock); close(conn->sock);
@ -229,7 +229,7 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp,
{ {
*err_no = ENOSPC; *err_no = ENOSPC;
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, " \
"connections: %d of server %s:%d " \ "connections: %d of server %s:%u " \
"exceed limit: %d", __LINE__, \ "exceed limit: %d", __LINE__, \
cm->total_count, conn->ip_addr, \ cm->total_count, conn->ip_addr, \
conn->port, cp->max_count_per_entry); conn->port, cp->max_count_per_entry);
@ -284,7 +284,7 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp,
} }
logDebug("file: "__FILE__", line: %d, " \ logDebug("file: "__FILE__", line: %d, " \
"server %s:%d, new connection: %d, " \ "server %s:%u, new connection: %d, " \
"total_count: %d, free_count: %d", \ "total_count: %d, free_count: %d", \
__LINE__, conn->ip_addr, conn->port, \ __LINE__, conn->ip_addr, conn->port, \
node->conn->sock, cm->total_count, \ node->conn->sock, cm->total_count, \
@ -332,7 +332,7 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp,
cm->total_count--; cm->total_count--;
logDebug("file: "__FILE__", line: %d, " \ logDebug("file: "__FILE__", line: %d, " \
"server %s:%d, connection: %d idle " \ "server %s:%u, connection: %d idle " \
"time: %d exceeds max idle time: %d, "\ "time: %d exceeds max idle time: %d, "\
"total_count: %d, free_count: %d", \ "total_count: %d, free_count: %d", \
__LINE__, conn->ip_addr, conn->port, \ __LINE__, conn->ip_addr, conn->port, \
@ -348,7 +348,7 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp,
pthread_mutex_unlock(&cm->lock); pthread_mutex_unlock(&cm->lock);
logDebug("file: "__FILE__", line: %d, " \ logDebug("file: "__FILE__", line: %d, " \
"server %s:%d, reuse connection: %d, " \ "server %s:%u, reuse connection: %d, " \
"total_count: %d, free_count: %d", "total_count: %d, free_count: %d",
__LINE__, conn->ip_addr, conn->port, __LINE__, conn->ip_addr, conn->port,
ci->sock, cm->total_count, cm->free_count); 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) if (cm == NULL)
{ {
logError("file: "__FILE__", line: %d, " \ 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); conn->ip_addr, conn->port);
return ENOENT; return ENOENT;
} }
@ -383,7 +383,7 @@ int conn_pool_close_connection_ex(ConnectionPool *cp, ConnectionInfo *conn,
if (node->manager != cm) if (node->manager != cm)
{ {
logError("file: "__FILE__", line: %d, " \ 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); __LINE__, conn->ip_addr, conn->port);
return EINVAL; return EINVAL;
} }
@ -394,7 +394,7 @@ int conn_pool_close_connection_ex(ConnectionPool *cp, ConnectionInfo *conn,
cm->total_count--; cm->total_count--;
logDebug("file: "__FILE__", line: %d, " logDebug("file: "__FILE__", line: %d, "
"server %s:%d, release connection: %d, " "server %s:%u, release connection: %d, "
"total_count: %d, free_count: %d", "total_count: %d, free_count: %d",
__LINE__, conn->ip_addr, conn->port, __LINE__, conn->ip_addr, conn->port,
conn->sock, cm->total_count, cm->free_count); 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++; cm->free_count++;
logDebug("file: "__FILE__", line: %d, " \ logDebug("file: "__FILE__", line: %d, " \
"server %s:%d, free connection: %d, " \ "server %s:%u, free connection: %d, " \
"total_count: %d, free_count: %d", "total_count: %d, free_count: %d",
__LINE__, conn->ip_addr, conn->port, __LINE__, conn->ip_addr, conn->port,
conn->sock, cm->total_count, cm->free_count); conn->sock, cm->total_count, cm->free_count);

View File

@ -131,7 +131,7 @@ int get_url_content_ex(const char *url, const int url_len,
close(sock); close(sock);
sprintf(error_info, "file: "__FILE__", line: %d, " \ 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, \ "error info: %s", __LINE__, domain_name, \
port, result, STRERROR(result)); 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), \ out_len = snprintf(out_buff, sizeof(out_buff), \
"GET %s HTTP/1.0\r\n" \ "GET %s HTTP/1.0\r\n" \
"Host: %s:%d\r\n" \ "Host: %s:%u\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n" \
"\r\n", pURI, domain_name, port); "\r\n", pURI, domain_name, port);
if ((result=tcpsenddata(sock, out_buff, out_len, network_timeout)) != 0) 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); close(sock);
sprintf(error_info, "file: "__FILE__", line: %d, " \ 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, \ "error info: %s", __LINE__, domain_name, \
port, result, STRERROR(result)); port, result, STRERROR(result));
@ -206,7 +206,7 @@ int get_url_content_ex(const char *url, const int url_len,
} }
else { else {
sprintf(error_info, "file: "__FILE__", line: %d, " \ 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, \ "error info: %s", __LINE__, domain_name, \
port, result, STRERROR(result)); port, result, STRERROR(result));
@ -218,7 +218,7 @@ int get_url_content_ex(const char *url, const int url_len,
if (pContent == NULL) if (pContent == NULL)
{ {
sprintf(error_info, "file: "__FILE__", line: %d, " \ 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); __LINE__, domain_name, port);
result = EINVAL; result = EINVAL;
@ -230,7 +230,7 @@ int get_url_content_ex(const char *url, const int url_len,
if (pSpace == NULL || pSpace >= pContent) if (pSpace == NULL || pSpace >= pContent)
{ {
sprintf(error_info, "file: "__FILE__", line: %d, " \ 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); __LINE__, domain_name, port);
result = EINVAL; result = EINVAL;

View File

@ -124,14 +124,14 @@ static int fast_multi_sock_client_do_send(FastMultiSockClient *client,
break; break;
} else if (errno == EINTR) { //should retry } else if (errno == EINTR) { //should retry
logDebug("file: "__FILE__", line: %d, " logDebug("file: "__FILE__", line: %d, "
"server: %s:%d, ignore interupt signal", "server: %s:%u, ignore interupt signal",
__LINE__, entry->conn->ip_addr, __LINE__, entry->conn->ip_addr,
entry->conn->port); entry->conn->port);
continue; continue;
} else { } else {
result = errno != 0 ? errno : ECONNRESET; result = errno != 0 ? errno : ECONNRESET;
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"send to server %s:%d fail, " "send to server %s:%u fail, "
"errno: %d, error info: %s", "errno: %d, error info: %s",
__LINE__, entry->conn->ip_addr, __LINE__, entry->conn->ip_addr,
entry->conn->port, entry->conn->port,
@ -141,7 +141,7 @@ static int fast_multi_sock_client_do_send(FastMultiSockClient *client,
} }
} else if (bytes == 0) { } else if (bytes == 0) {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"send to server %s:%d, sock: %d fail, " "send to server %s:%u, sock: %d fail, "
"connection disconnected", "connection disconnected",
__LINE__, entry->conn->ip_addr, entry->conn->port, __LINE__, entry->conn->ip_addr, entry->conn->port,
entry->conn->sock); 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].error_no = ENOTCONN;
client->entries[i].done = true; client->entries[i].done = true;
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"NOT connected to %s:%d", "NOT connected to %s:%u",
__LINE__, client->entries[i].conn->ip_addr, __LINE__, client->entries[i].conn->ip_addr,
client->entries[i].conn->port); client->entries[i].conn->port);
continue; continue;
@ -239,14 +239,14 @@ static int fast_multi_sock_client_do_recv(FastMultiSockClient *client,
break; break;
} else if (errno == EINTR) { //should retry } else if (errno == EINTR) { //should retry
logDebug("file: "__FILE__", line: %d, " logDebug("file: "__FILE__", line: %d, "
"server: %s:%d, ignore interupt signal", "server: %s:%u, ignore interupt signal",
__LINE__, entry->conn->ip_addr, __LINE__, entry->conn->ip_addr,
entry->conn->port); entry->conn->port);
continue; continue;
} else { } else {
result = errno != 0 ? errno : ECONNRESET; result = errno != 0 ? errno : ECONNRESET;
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"server: %s:%d, recv failed, " "server: %s:%u, recv failed, "
"errno: %d, error info: %s", "errno: %d, error info: %s",
__LINE__, entry->conn->ip_addr, __LINE__, entry->conn->ip_addr,
entry->conn->port, entry->conn->port,
@ -256,7 +256,7 @@ static int fast_multi_sock_client_do_recv(FastMultiSockClient *client,
} }
} else if (bytes == 0) { } else if (bytes == 0) {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"server: %s:%d, sock: %d, recv failed, " "server: %s:%u, sock: %d, recv failed, "
"connection disconnected", "connection disconnected",
__LINE__, entry->conn->ip_addr, entry->conn->port, __LINE__, entry->conn->ip_addr, entry->conn->port,
entry->conn->sock); 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); body_length = client->get_body_length_func(&entry->recv_buffer);
if (body_length < 0) { if (body_length < 0) {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"server: %s:%d, body_length: %d < 0", "server: %s:%u, body_length: %d < 0",
__LINE__, entry->conn->ip_addr, __LINE__, entry->conn->ip_addr,
entry->conn->port, body_length); entry->conn->port, body_length);
result = EPIPE; result = EPIPE;
@ -322,7 +322,7 @@ static int fast_multi_sock_client_deal_io(FastMultiSockClient *client)
if (event & IOEVENT_ERROR) { if (event & IOEVENT_ERROR) {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"server: %s:%d, recv error event: %d, " "server: %s:%u, recv error event: %d, "
"connection reset", __LINE__, "connection reset", __LINE__,
entry->conn->ip_addr, entry->conn->port, event); 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, fast_multi_sock_client_finish(client,
client->entries + i, ETIMEDOUT); client->entries + i, ETIMEDOUT);
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"recv from %s:%d timedout", "recv from %s:%u timedout",
__LINE__, client->entries[i].conn->ip_addr, __LINE__, client->entries[i].conn->ip_addr,
client->entries[i].conn->port); client->entries[i].conn->port);
} }

View File

@ -244,7 +244,7 @@ static int fc_server_check_ip_port(FCServerConfig *ctx,
id2 = previous->server->id; id2 = previous->server->id;
} }
logError("file: "__FILE__", line: %d, " 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__, "the server ids: %d, %d", __LINE__,
config_filename, previous->ip_addr.str, config_filename, previous->ip_addr.str,
previous->port, id1, id2); previous->port, id1, id2);
@ -610,7 +610,7 @@ static int check_addresses_duplicate(FCServerConfig *ctx,
if (fc_server_cmp_address_ptr(ppaddr, pprevious) == 0) { if (fc_server_cmp_address_ptr(ppaddr, pprevious) == 0) {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"config filename: %s, section: %s, group: %.*s, " "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, config_filename, section_name,
group_addr->server_group->group_name.len, group_addr->server_group->group_name.len,
group_addr->server_group->group_name.str, 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)) { if (!ctx->share_between_groups && (count > 1 && addr->conn.port > 0)) {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"config filename: %s, section: %s, " "config filename: %s, section: %s, "
"host %s:%d belongs to %d groups", "host %s:%u belongs to %d groups",
__LINE__, config_filename, section_name, __LINE__, config_filename, section_name,
addr->conn.ip_addr, addr->conn.port, count); addr->conn.ip_addr, addr->conn.port, count);
return EEXIST; return EEXIST;
@ -1324,7 +1324,7 @@ static void fc_group_servers_to_string(FCServerConfig *ctx,
gaddr->server_group->group_name.str, gaddr->server_group->group_name.str,
SERVER_ITEM_HOST_AFFIX_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); (*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; end = gaddr->address_array.addrs + gaddr->address_array.count;
for (addr=gaddr->address_array.addrs; addr<end; addr++) { for (addr=gaddr->address_array.addrs; addr<end; addr++) {
logInfo(" %d. %s:%d", (int)(addr - gaddr->address_array.addrs + 1), logInfo(" %d. %s:%u", (int)(addr - gaddr->address_array.addrs + 1),
(*addr)->conn.ip_addr, (*addr)->conn.port); (*addr)->conn.ip_addr, (*addr)->conn.port);
} }
} }

View File

@ -720,7 +720,7 @@ int socketClientEx2(int af, const char *server_ip,
if (*err_no != 0) if (*err_no != 0)
{ {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"connect to %s:%d fail, " "connect to %s:%u fail, "
"errno: %d, error info: %s", "errno: %d, error info: %s",
__LINE__, server_ip, server_port, __LINE__, server_ip, server_port,
*err_no, STRERROR(*err_no)); *err_no, STRERROR(*err_no));