replace type in_addr_t to in_addr_64_t

use_iouring
YuQing 2023-11-24 15:25:14 +08:00
parent 4eb30adb1a
commit 700a5bcaec
6 changed files with 21 additions and 16 deletions

View File

@ -1,4 +1,7 @@
Version 1.71 2023-11-24
* full support IPv6 by pull request #47
Version 1.70 2023-09-30
* get full mac address of infiniband NIC under Linux
* struct fast_task_info add field conn for RDMA connection

View File

@ -160,9 +160,10 @@ const char *get_next_local_ip(const char *previous_ip)
pEnd = g_local_host_ip_addrs + \
IP_ADDRESS_SIZE * g_local_host_ip_count;
for (p=g_local_host_ip_addrs; p<pEnd; p+=IP_ADDRESS_SIZE)
{
if (strcmp(p, LOCAL_LOOPBACK_IPv4) != 0 &&
strcmp(p, LOCAL_LOOPBACK_IPv6) !=0 )
{
if (strcmp(p, LOCAL_LOOPBACK_IPv4) != 0 &&
strcmp(p, LOCAL_LOOPBACK_IPv6) != 0 &&
strcasecmp(p, "fe80::1") != 0)
{
if (found)
{
@ -173,7 +174,7 @@ const char *get_next_local_ip(const char *previous_ip)
found = true;
}
}
}
}
return NULL;
}

View File

@ -25,7 +25,7 @@
#include "common_define.h"
#define FAST_IF_ALIAS_PREFIX_MAX_SIZE 32
#define FAST_MAX_LOCAL_IP_ADDRS 16
#define FAST_MAX_LOCAL_IP_ADDRS 32
#define LOCAL_LOOPBACK_IPv4 "127.0.0.1"
#define LOCAL_LOOPBACK_IPv6 "::1"

View File

@ -2005,7 +2005,7 @@ static int parse_cidr_ips(const char *ip_addr, in_addr_64_t **allow_ip_addrs,
int host_bits;
int bits;
uint32_t hip;
in_addr_t nip;
in_addr_64_t nip;
int h;
int count;
int result;
@ -2237,7 +2237,7 @@ static int parse_range_hosts(const char *value, char *pStart, char *pEnd,
return 0;
}
int load_allow_hosts(IniContext *pIniContext, \
int load_allow_hosts(IniContext *pIniContext,
in_addr_64_t **allow_ip_addrs, int *allow_ip_count)
{
int result;
@ -2252,7 +2252,7 @@ int load_allow_hosts(IniContext *pIniContext, \
int nHeadLen;
int nValueLen;
int i;
in_addr_t addr;
in_addr_64_t addr;
char hostname[256];
if ((pItemStart=iniGetValuesEx(NULL, "allow_hosts", \
@ -2359,13 +2359,13 @@ int load_allow_hosts(IniContext *pIniContext, \
if (*allow_ip_count == 0)
{
logWarning("file: "__FILE__", line: %d, " \
logWarning("file: "__FILE__", line: %d, "
"allow ip count: 0", __LINE__);
}
if (*allow_ip_count > 0)
{
qsort(*allow_ip_addrs, *allow_ip_count, sizeof(in_addr_t), \
qsort(*allow_ip_addrs, *allow_ip_count, sizeof(in_addr_64_t),
cmp_by_ip_addr_t);
}
@ -2384,7 +2384,7 @@ int load_allow_hosts(IniContext *pIniContext, \
int cmp_by_ip_addr_t(const void *p1, const void *p2)
{
return memcmp((in_addr_t *)p1, (in_addr_t *)p2, sizeof(in_addr_t));
return memcmp((in_addr_64_t *)p1, (in_addr_64_t *)p2, sizeof(in_addr_64_t));
}
int parse_bytes(const char *pStr, const int default_unit_bytes, int64_t *bytes)

View File

@ -1117,7 +1117,7 @@ in_addr_64_t getIpaddr(getnamefunc getname, int sock,
if (convert.sa.addr.sa_family == AF_INET) {
return convert.sa.addr4.sin_addr.s_addr;
} else {
return *((in_addr_64_t *)&convert.sa.addr6.sin6_addr);
return *((in_addr_64_t *)((char *)&convert.sa.addr6.sin6_addr + 8));
}
}
@ -1218,7 +1218,7 @@ in_addr_64_t getIpaddrByName(const char *name, char *buff, const int bufferSize)
}
}
ip_addr = *((in_addr_64_t *)&ipv6->sin6_addr);
ip_addr = *((in_addr_64_t *)((char *)&ipv6->sin6_addr + 8));
freeaddrinfo(res);
return ip_addr;
}
@ -1268,7 +1268,7 @@ int getIpaddrsByName(const char *name,
continue;
}
} else {
addr = (struct sockaddr_in *) res->ai_addr;
addr = (struct sockaddr_in *)res->ai_addr;
if (inet_ntop(res->ai_family, &addr->sin_addr,
ip_addr_arr[ip_count].ip_addr, INET6_ADDRSTRLEN) == NULL)
{

View File

@ -30,6 +30,7 @@
static bool g_continue_flag = true;
static int64_t produce_count = 0;
static int64_t consume_count = 0;
static struct fast_task_queue free_queue;
static struct fast_blocked_queue blocked_queue;
#define MAX_USLEEP 10000
@ -51,7 +52,7 @@ void *producer_thread(void *arg)
printf("produce count: %"PRId64"\n", count);
}
pTask = free_queue_pop();
pTask = free_queue_pop(&free_queue);
if (pTask != NULL) {
blocked_queue_push(&blocked_queue, pTask);
}
@ -99,7 +100,7 @@ int main(int argc, char *argv[])
return errno;
}
result = free_queue_init(1024, min_buff_size, \
result = free_queue_init(&free_queue, 1024, min_buff_size,
max_buff_size, arg_size);
if (result != 0) {
return result;