add function fc_check_realloc_iovec_array
parent
e6be76eb74
commit
ba1f8eb38f
3
HISTORY
3
HISTORY
|
|
@ -1,8 +1,9 @@
|
|||
|
||||
Version 1.52 2021-06-02
|
||||
Version 1.52 2021-06-08
|
||||
* process_stop more gracefully (kill -9 on timeout)
|
||||
* add function fc_queue_pop_to_queue_ex
|
||||
* add function get_path_block_size and get_device_block_size
|
||||
* add function fc_check_realloc_iovec_array
|
||||
|
||||
Version 1.51 2021-05-27
|
||||
* fast_mblock.[hc]: support batch alloc and batch free
|
||||
|
|
|
|||
|
|
@ -249,6 +249,13 @@ typedef struct
|
|||
pthread_cond_t cond;
|
||||
} pthread_lock_cond_pair_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int alloc;
|
||||
int count;
|
||||
struct iovec *iovs;
|
||||
} iovec_array_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char buff[PATH_MAX];
|
||||
|
|
@ -293,6 +300,12 @@ typedef void* (*MallocFunc)(size_t size);
|
|||
//for printf format %.*s
|
||||
#define FC_PRINTF_STAR_STRING_PARAMS(s) (s).len, (s).str
|
||||
|
||||
#define FC_SET_IOVEC(iovec, buff, len) \
|
||||
do { \
|
||||
(iovec).iov_base = buff; \
|
||||
(iovec).iov_len = len; \
|
||||
} while (0)
|
||||
|
||||
#define FC_SET_STRING(dest, src) \
|
||||
do { \
|
||||
(dest).str = src; \
|
||||
|
|
|
|||
|
|
@ -84,7 +84,13 @@ struct fast_task_info
|
|||
char client_ip[IP_ADDRESS_SIZE];
|
||||
};
|
||||
void *arg; //extra argument pointer
|
||||
char *data; //buffer for write or recv
|
||||
char *data; //buffer for write or read
|
||||
|
||||
struct {
|
||||
struct iovec *iovs;
|
||||
int count;
|
||||
} iovec_array; //for writev
|
||||
|
||||
int size; //alloc size
|
||||
int length; //data length
|
||||
int offset; //current offset
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include "common_define.h"
|
||||
#include "fc_memory.h"
|
||||
#include "ini_file_reader.h"
|
||||
|
||||
#define NORMALIZE_FLAGS_URL_ENABLED 1
|
||||
|
|
@ -1104,6 +1105,38 @@ int fc_check_filename(const string_t *filename, const char *caption);
|
|||
*/
|
||||
bool is_digital_string(const char *str);
|
||||
|
||||
static inline int fc_check_realloc_iovec_array(
|
||||
iovec_array_t *array, const int target_size)
|
||||
{
|
||||
int new_alloc;
|
||||
struct iovec *new_iovs;
|
||||
|
||||
if (array->alloc >= target_size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (array->alloc == 0) {
|
||||
new_alloc = 64;
|
||||
} else {
|
||||
new_alloc = array->alloc * 2;
|
||||
}
|
||||
while (new_alloc < target_size) {
|
||||
new_alloc *= 2;
|
||||
}
|
||||
|
||||
new_iovs = (struct iovec *)fc_malloc(
|
||||
sizeof(struct iovec) * new_alloc);
|
||||
if (new_iovs == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (array->iovs != NULL) {
|
||||
free(array->iovs);
|
||||
}
|
||||
array->iovs = new_iovs;
|
||||
array->alloc = new_alloc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue