🐞 fix(TSG-7855): 修改哈希查找的类型

This commit is contained in:
“pengxuanzheng”
2021-09-22 18:12:00 +08:00
parent d775b9d7e4
commit 9250031fac
2 changed files with 5 additions and 5 deletions

View File

@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
userdata_t data = {&finished}; userdata_t data = {&finished};
hos_instance hos_instance = NULL; hos_instance hos_instance = NULL;
char object[1024]; char object[1024];
const char *bucket = "hos_test_not_exit_bucket"; const char *bucket = "hos_test_bucket";
if (stat(file_name, &buffer) == -1) if (stat(file_name, &buffer) == -1)
{ {

View File

@@ -8,7 +8,7 @@
void add_fd_context(hos_fd_context_t **handle, hos_fd_context_t *input) void add_fd_context(hos_fd_context_t **handle, hos_fd_context_t *input)
{ {
hos_fd_context_t *value = NULL; hos_fd_context_t *value = NULL;
HASH_FIND_INT(*handle, (int *)&input->fd, value); HASH_FIND(hh,*handle,&input->fd,sizeof(input->fd),value);
if (value == NULL) if (value == NULL)
{ {
value = (hos_fd_context_t *)malloc(sizeof(hos_fd_context_t)); value = (hos_fd_context_t *)malloc(sizeof(hos_fd_context_t));
@@ -17,7 +17,7 @@ void add_fd_context(hos_fd_context_t **handle, hos_fd_context_t *input)
value->bucket = (char *)calloc(1, strlen(input->bucket) + 1); value->bucket = (char *)calloc(1, strlen(input->bucket) + 1);
memcpy(value->bucket, input->bucket, strlen(input->bucket)); memcpy(value->bucket, input->bucket, strlen(input->bucket));
memcpy(value->object, input->object, strlen(input->object)); memcpy(value->object, input->object, strlen(input->object));
HASH_ADD_INT(*handle, fd, value); HASH_ADD(hh,*handle,fd,sizeof(long),value);
} }
else else
{ {
@@ -50,7 +50,7 @@ void add_fd_context(hos_fd_context_t **handle, hos_fd_context_t *input)
hos_fd_context_t *find_context_by_fd(hos_fd_context_t *handle, size_t fd) hos_fd_context_t *find_context_by_fd(hos_fd_context_t *handle, size_t fd)
{ {
hos_fd_context_t *value = NULL; hos_fd_context_t *value = NULL;
HASH_FIND_INT(handle, &fd, value); HASH_FIND(hh,handle,&fd,sizeof(long),value);
return value; return value;
} }
@@ -58,7 +58,7 @@ void delete_context_by_fd(hos_fd_context_t **handle, size_t fd)
{ {
hos_fd_context_t *value = NULL; hos_fd_context_t *value = NULL;
HASH_FIND_INT(*handle, &fd, value); HASH_FIND(hh,*handle,&fd,sizeof(long),value);
if (value) if (value)
{ {
if (value->bucket) if (value->bucket)