use newest files from libfastcommon

pull/48/head
yuqing 2014-08-10 14:01:58 +08:00
parent be6e9f1141
commit 95800612dc
8 changed files with 21 additions and 15 deletions

View File

@ -5,7 +5,7 @@ Version 5.03 2014-08-10
* use newest logger from libfastcommon
* patches by liangry@ucweb.com
* bug fixed: can't sync large files cause by v5.02
* use newest ioevent_loop from libfastcommon
* use newest files from libfastcommon
Version 5.02 2014-07-20
* corect README spell mistake

View File

@ -3,6 +3,7 @@
#include <errno.h>
#include <sys/resource.h>
#include <pthread.h>
#include <assert.h>
#include "fast_mblock.h"
#include "logger.h"
#include "shared_func.h"
@ -21,7 +22,7 @@ int fast_mblock_init(struct fast_mblock_man *mblock, const int element_size, \
return EINVAL;
}
mblock->element_size = element_size;
mblock->element_size = MEM_ALIGN(element_size);
if (alloc_elements_once > 0)
{
mblock->alloc_elements_once = alloc_elements_once;
@ -30,7 +31,7 @@ int fast_mblock_init(struct fast_mblock_man *mblock, const int element_size, \
{
int block_size;
block_size = MEM_ALIGN(sizeof(struct fast_mblock_node) \
+ element_size);
+ mblock->element_size);
mblock->alloc_elements_once = (1024 * 1024) / block_size;
}
@ -44,6 +45,7 @@ int fast_mblock_init(struct fast_mblock_man *mblock, const int element_size, \
mblock->malloc_chain_head = NULL;
mblock->free_chain_head = NULL;
mblock->total_count = 0;
return 0;
}
@ -84,12 +86,12 @@ static int fast_mblock_prealloc(struct fast_mblock_man *mblock)
pNode = (struct fast_mblock_node *)p;
pNode->next = (struct fast_mblock_node *)(p + block_size);
}
((struct fast_mblock_node *)pLast)->next = NULL;
mblock->free_chain_head = (struct fast_mblock_node *)pTrunkStart;
pMallocNode->next = mblock->malloc_chain_head;
mblock->malloc_chain_head = pMallocNode;
mblock->total_count += mblock->alloc_elements_once;
return 0;
}
@ -114,6 +116,7 @@ void fast_mblock_destroy(struct fast_mblock_man *mblock)
}
mblock->malloc_chain_head = NULL;
mblock->free_chain_head = NULL;
mblock->total_count = 0;
pthread_mutex_destroy(&(mblock->lock));
}
@ -189,7 +192,7 @@ int fast_mblock_free(struct fast_mblock_man *mblock, \
return 0;
}
int fast_mblock_count(struct fast_mblock_man *mblock)
int fast_mblock_free_count(struct fast_mblock_man *mblock)
{
struct fast_mblock_node *pNode;
int count;

View File

@ -37,11 +37,12 @@ struct fast_mblock_man
struct fast_mblock_malloc *malloc_chain_head; //malloc chain to be freed
int element_size; //element size
int alloc_elements_once; //alloc elements once
int total_count; //total element count
pthread_mutex_t lock; //the lock for read / write free node chain
};
#define fast_mblock_to_node_ptr(data_ptr) \
(struct fast_mblock_node *)(data_ptr - ((size_t)(char *) \
(struct fast_mblock_node *)((char *)data_ptr - ((size_t)(char *) \
&((struct fast_mblock_node *)0)->data))
#ifdef __cplusplus
@ -90,7 +91,9 @@ parameters:
mblock: the mblock pointer
return the free node count of the mblock, return -1 if fail
*/
int fast_mblock_count(struct fast_mblock_man *mblock);
int fast_mblock_free_count(struct fast_mblock_man *mblock);
#define fast_mblock_total_count(mblock) (mblock)->total_count
#ifdef __cplusplus
}

View File

@ -47,7 +47,7 @@ struct nio_thread_data
struct fast_task_info
{
IOEventEntry event;
IOEventEntry event; //must first
char client_ip[IP_ADDRESS_SIZE];
void *arg; //extra argument pointer
char *data; //buffer for write or recv

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include "pthread_func.h"
#include "hash.h"

View File

@ -19,20 +19,20 @@ static void deal_ioevents(IOEventPoller *ioevent, const int count)
static void deal_timeouts(FastTimerEntry *head)
{
FastTimerEntry *entry;
FastTimerEntry *curent;
FastTimerEntry *current;
IOEventEntry *pEventEntry;
entry = head->next;
while (entry != NULL)
{
curent = entry;
current = entry;
entry = entry->next;
pEventEntry = (IOEventEntry *)curent->data;
pEventEntry = (IOEventEntry *)current->data;
if (pEventEntry != NULL)
{
pEventEntry->callback(pEventEntry->fd, IOEVENT_TIMEOUT,
curent->data);
current->data);
}
}
}

View File

@ -13,6 +13,7 @@
#include <ctype.h>
#include <unistd.h>
#include <signal.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <netinet/in.h>
@ -1770,8 +1771,7 @@ int parse_bytes(char *pStr, const int default_unit_bytes, int64_t *bytes)
if (*bytes < 0)
{
logError("file: "__FILE__", line: %d, " \
"bytes: %"PRId64" < 0", \
__LINE__, *bytes);
"bytes: %"PRId64" < 0", __LINE__, *bytes);
return EINVAL;
}

View File

@ -239,7 +239,6 @@ int tcpsenddata(int sock, void* data, const int size, const int timeout)
if (pollfds.revents & POLLHUP)
{
return ENOTCONN;
break;
}
#endif