Skip to content

Commit c700540

Browse files
author
ubuntu14
committed
fixed some bugs, add some samples, and release 3.1.4.3
1 parent 256d4cf commit c700540

File tree

20 files changed

+505
-61
lines changed

20 files changed

+505
-61
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ endif
6161
##############################################################################
6262

6363
.PHONY = check help all_lib all samples all clean install uninstall uninstall_all build_bin build_src build_one
64-
VERSION = 3.1.4
64+
VERSION = 3.1.4.3
6565

6666
help:
6767
@(echo "usage: make help|all|all_lib|all_samples|clean|install|uninstall|uninstall_all|build_bin|build_src|build_one")

changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
�޸���ʷ�б���
22
------------------------------------------------------------------------
3+
93) 2015.12.29 --- acl 3.1.4.3 �汾������(�޸��˼������� BUG)
34
92) 2015.12.21 --- acl 3.1.4.2 �汾������(�޸���һ������ BUG)
45
91) 2015.12.21 --- acl 3.1.4.1 �汾������(�޸��˼������� BUG)
56
90) 2015.12.20 --- acl 3.1.4 �汾������

lib_acl/changes.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
�޸���ʷ�б���
22

33
------------------------------------------------------------------------
4+
523) 2015.12.28
5+
523.1) acl_read_wait.c �еĺ��� acl_read_wait �� 32 λ�ĵͰ汾 LINUX ƽ̨��
6+
ʹ�� epoll ����ģ�����ʱ���������⣬���Ը��� poll ������ʵ�ֶ���ʱ����
7+
8+
522) 2015.12.24
9+
522.1) bugfix: �޸��� valgrind ������ acl_xml_parse.c �к��� cdata_prepare
10+
����ָ��Ƿ���������
11+
12+
521) 2015.12.23
13+
521.1) bugfix: acl_xml_parse.c/acl_xml2_parse.c ������һ���յ� CDATA ʱ������
14+
415
520) 2015.12.21
516
520.1) bugfix: master_sig.c ���ڶ�����ʱӦ��ʹ�� acl_vstream_read��������
617
����ϵͳ API read��������γ���ѭ��

lib_acl/src/init/acl_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include "init.h"
2626

27-
static char *version = "acl_3.1.4.2";
27+
static char *version = "acl_3.1.4.3";
2828

2929
const char *acl_version(void)
3030
{

lib_acl/src/stdlib/iostuff/acl_read_wait.c

Lines changed: 74 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,81 +22,119 @@
2222
#include "stdlib/acl_iostuff.h"
2323
#include "../../init/init.h"
2424

25-
#if defined(LINUX2) && !defined(MINGW)
25+
#if defined(LINUX2) && !defined(MINGW) && defined(USE_EPOLL)
2626

2727
#include "init/acl_init.h"
2828
#include "thread/acl_pthread.h"
2929
#include <sys/epoll.h>
3030

31-
static int *main_epoll_read_fd = NULL;
31+
typedef struct EPOLL_CTX
32+
{
33+
acl_pthread_t tid;
34+
int epfd;
35+
} EPOLL_CTX;
36+
37+
static EPOLL_CTX *main_epoll_ctx = NULL;
3238

3339
static void main_epoll_end(void)
3440
{
35-
if (main_epoll_read_fd != NULL) {
36-
close(*main_epoll_read_fd);
37-
acl_myfree(main_epoll_read_fd);
41+
const char *myname = "main_epoll_end";
42+
43+
if (main_epoll_ctx != NULL) {
44+
acl_msg_info("%s(%d), %s: close epoll_fd: %d, tid: %lu, %lu",
45+
__FILE__, __LINE__, myname, main_epoll_ctx->epfd,
46+
main_epoll_ctx->tid, acl_pthread_self());
47+
48+
close(main_epoll_ctx->epfd);
49+
acl_myfree(main_epoll_ctx);
50+
main_epoll_ctx = NULL;
3851
}
3952
}
4053

4154
static acl_pthread_key_t epoll_key;
4255
static acl_pthread_once_t epoll_once = ACL_PTHREAD_ONCE_INIT;
4356

44-
static void thread_epoll_end(void *buf)
57+
static void thread_epoll_end(void *ctx)
4558
{
46-
int *epoll_fd = (int*) buf;
59+
const char *myname = "thread_epoll_end";
60+
EPOLL_CTX *epoll_ctx = (EPOLL_CTX*) ctx;
4761

48-
close(*epoll_fd);
49-
acl_myfree(epoll_fd);
62+
acl_msg_info("%s(%d), %s: close epoll_fd: %d, tid: %lu, %lu",
63+
__FILE__, __LINE__, myname, epoll_ctx->epfd,
64+
epoll_ctx->tid, acl_pthread_self());
65+
66+
close(epoll_ctx->epfd);
67+
acl_myfree(epoll_ctx);
5068
}
5169

52-
static void thread_epoll_init(void)
70+
static void thread_epoll_once(void)
5371
{
5472
acl_assert(acl_pthread_key_create(&epoll_key, thread_epoll_end) == 0);
5573
}
5674

75+
static EPOLL_CTX *thread_epoll_init(void)
76+
{
77+
const char *myname = "thread_epoll_init";
78+
EPOLL_CTX *epoll_ctx = (EPOLL_CTX*) acl_mymalloc(sizeof(EPOLL_CTX));
79+
80+
acl_assert(acl_pthread_setspecific(epoll_key, epoll_ctx) == 0);
81+
82+
epoll_ctx->tid = acl_pthread_self();
83+
epoll_ctx->epfd = epoll_create(1);
84+
85+
if (acl_pthread_self() == acl_main_thread_self()) {
86+
main_epoll_ctx = epoll_ctx;
87+
atexit(main_epoll_end);
88+
acl_msg_info("%s(%d): %s, create epoll_fd: %d, tid: %lu, %lu",
89+
__FILE__, __LINE__, myname, epoll_ctx->epfd,
90+
epoll_ctx->tid, acl_pthread_self());
91+
} else {
92+
acl_msg_info("%s(%d): %s, create epoll_fd: %d, tid: %lu, %lu",
93+
__FILE__, __LINE__, myname, epoll_ctx->epfd,
94+
epoll_ctx->tid, acl_pthread_self());
95+
}
96+
97+
return epoll_ctx;
98+
}
99+
57100
int acl_read_wait(ACL_SOCKET fd, int timeout)
58101
{
59102
const char *myname = "acl_read_wait";
60-
int op = EPOLL_CTL_ADD, delay = timeout * 1000, *epoll_fd, ret;
103+
int delay = timeout * 1000, ret;
104+
EPOLL_CTX *epoll_ctx;
61105
struct epoll_event ee, events[1];
62106

63-
acl_assert(acl_pthread_once(&epoll_once, thread_epoll_init) == 0);
64-
epoll_fd = (int*) acl_pthread_getspecific(epoll_key);
65-
if (epoll_fd == NULL) {
66-
epoll_fd = (int*) acl_mymalloc(sizeof(int));
67-
acl_assert(acl_pthread_setspecific(epoll_key, epoll_fd) == 0);
68-
if ((unsigned long) acl_pthread_self()
69-
== acl_main_thread_self())
70-
{
71-
main_epoll_read_fd = epoll_fd;
72-
atexit(main_epoll_end);
73-
}
74-
75-
*epoll_fd = epoll_create(1);
76-
}
107+
acl_assert(acl_pthread_once(&epoll_once, thread_epoll_once) == 0);
108+
epoll_ctx = (EPOLL_CTX*) acl_pthread_getspecific(epoll_key);
109+
if (epoll_ctx == NULL)
110+
epoll_ctx = thread_epoll_init();
77111

78112
ee.events = EPOLLIN | EPOLLHUP | EPOLLERR;
79113
ee.data.u64 = 0;
80114
ee.data.fd = fd;
81-
if (epoll_ctl(*epoll_fd, op, fd, &ee) == -1
115+
if (epoll_ctl(epoll_ctx->epfd, EPOLL_CTL_ADD, fd, &ee) == -1
82116
&& acl_last_error() != EEXIST)
83117
{
84-
acl_msg_error("%s(%d): epoll_ctl error: %s, fd: %d",
85-
myname, __LINE__, acl_last_serror(), fd);
118+
acl_msg_error("%s(%d): epoll_ctl error: %s, fd: %d, epfd: %d,"
119+
" tid: %lu, %lu", myname, __LINE__, acl_last_serror(),
120+
fd, epoll_ctx->epfd, epoll_ctx->tid,
121+
acl_pthread_self());
86122
return -1;
87123
}
88124

89125
for (;;) {
90-
ret = epoll_wait(*epoll_fd, events, 1, delay);
126+
ret = epoll_wait(epoll_ctx->epfd, events, 1, delay);
91127

92128
if (ret == -1) {
93129
if (acl_last_error() == ACL_EINTR) {
94130
acl_msg_warn(">>>>catch EINTR, try again<<<");
95131
continue;
96132
}
97133

98-
acl_msg_error("%s(%d): epoll_wait error: %s, fd: %d",
99-
myname, __LINE__, acl_last_serror(), fd);
134+
acl_msg_error("%s(%d): epoll_wait error: %s, fd: %d,"
135+
" epfd: %d, tid: %lu, %lu", myname, __LINE__,
136+
acl_last_serror(), fd, epoll_ctx->epfd,
137+
epoll_ctx->tid, acl_pthread_self());
100138
ret = -1;
101139
break;
102140
} else if (ret == 0) {
@@ -118,9 +156,11 @@ int acl_read_wait(ACL_SOCKET fd, int timeout)
118156
ee.events = 0;
119157
ee.data.u64 = 0;
120158
ee.data.fd = fd;
121-
if (epoll_ctl(*epoll_fd, EPOLL_CTL_DEL, fd, &ee) == -1) {
122-
acl_msg_error("%s(%d): epoll_ctl error: %s, fd: %d",
123-
myname, __LINE__, acl_last_serror(), fd);
159+
if (epoll_ctl(epoll_ctx->epfd, EPOLL_CTL_DEL, fd, &ee) == -1) {
160+
acl_msg_error("%s(%d): epoll_ctl error: %s, fd: %d, epfd: %d,"
161+
" tid: %lu, %lu", myname, __LINE__, acl_last_serror(),
162+
fd, epoll_ctx->epfd, epoll_ctx->tid,
163+
acl_pthread_self());
124164
return -1;
125165
}
126166

lib_acl/src/xml/acl_xml2_parse.c

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,8 @@ static const char *xml_parse_cdata(ACL_XML2 *xml, const char *data)
212212
*xml->ptr = 0;
213213
return data;
214214
}
215-
#define IS_CDATA(x) (*(x) == '[' \
216-
&& (*(x + 1) == 'C' || *(x + 1) == 'c') \
217-
&& (*(x + 2) == 'D' || *(x + 2) == 'd') \
218-
&& (*(x + 3) == 'A' || *(x + 3) == 'a') \
219-
&& (*(x + 4) == 'T' || *(x + 4) == 't') \
220-
&& (*(x + 5) == 'A' || *(x + 5) == 't') \
221-
&& *(x + 6) == '[')
222215

223-
static void cdata_prepare(ACL_XML2 *xml, int last_ch)
216+
static void cdata_prepare(ACL_XML2 *xml)
224217
{
225218
size_t cdata_len = sizeof("[CDATA[") - 1, len, max, i;
226219
ACL_XML2_NODE *curr_node = xml->curr_node;
@@ -252,12 +245,23 @@ static void cdata_prepare(ACL_XML2 *xml, int last_ch)
252245
curr_node->ltag_size = cdata_len;
253246
curr_node->ltag[curr_node->ltag_size] = 0;
254247

248+
#if 0
255249
if (xml->len < MIN_LEN)
256250
return;
257251
*xml->ptr++ = last_ch;
258252
xml->len--;
253+
#endif
259254
}
260255

256+
#define CDATA_SIZE (sizeof("[CDATA[") - 1)
257+
#define IS_CDATA(x) (*(x) == '[' \
258+
&& (*(x + 1) == 'C' || *(x + 1) == 'c') \
259+
&& (*(x + 2) == 'D' || *(x + 2) == 'd') \
260+
&& (*(x + 3) == 'A' || *(x + 3) == 'a') \
261+
&& (*(x + 4) == 'T' || *(x + 4) == 't') \
262+
&& (*(x + 5) == 'A' || *(x + 5) == 't') \
263+
&& *(x + 6) == '[')
264+
261265
static const char *xml_parse_meta_tag(ACL_XML2 *xml, const char *data)
262266
{
263267
int ch;
@@ -269,6 +273,7 @@ static const char *xml_parse_meta_tag(ACL_XML2 *xml, const char *data)
269273
xml->curr_node->ltag = xml->ptr;
270274

271275
while ((ch = *data) != 0) {
276+
#if 0
272277
if (IS_SPACE(ch) || ch == '>') {
273278
if (xml->len < MIN_LEN)
274279
return data;
@@ -289,6 +294,29 @@ static const char *xml_parse_meta_tag(ACL_XML2 *xml, const char *data)
289294
}
290295
break;
291296
}
297+
#else
298+
299+
if (xml->ptr - xml->curr_node->ltag >= (ssize_t) CDATA_SIZE
300+
&& IS_CDATA(xml->curr_node->ltag))
301+
{
302+
xml->curr_node->ltag_size =
303+
xml->ptr - xml->curr_node->ltag;
304+
cdata_prepare(xml);
305+
xml->curr_node->status = ACL_XML2_S_CDATA;
306+
xml->curr_node->flag |= ACL_XML2_F_CDATA;
307+
break;
308+
} else if (IS_SPACE(ch) || ch == '>') {
309+
xml->curr_node->ltag_size =
310+
xml->ptr - xml->curr_node->ltag;
311+
if (xml->len < MIN_LEN)
312+
return data;
313+
data++;
314+
*xml->ptr++ = 0;
315+
xml->len--;
316+
xml->curr_node->status = ACL_XML2_S_MTXT;
317+
break;
318+
}
319+
#endif
292320

293321
if (xml->len < MIN_LEN)
294322
return data;

lib_acl/src/xml/acl_xml_parse.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,17 @@ static const char *xml_parse_cdata(ACL_XML *xml, const char *data)
183183
&& (*(x + 5) == 'A' || *(x + 5) == 't') \
184184
&& *(x + 6) == '[')
185185

186+
#define CDATA_S sizeof("[CDATA[") - 1
187+
186188
static void cdata_prepare(ACL_XML_NODE *curr_node)
187189
{
188-
char *ptr = STR(curr_node->ltag) + sizeof("[CDATA[") - 1;
190+
char *ptr;
191+
192+
ACL_VSTRING_TERMINATE(curr_node->ltag);
193+
ptr = STR(curr_node->ltag) + sizeof("[CDATA[") - 1;
189194

190-
acl_vstring_strcpy(curr_node->text, ptr);
195+
if (*ptr)
196+
acl_vstring_strcpy(curr_node->text, ptr);
191197
ACL_VSTRING_AT_OFFSET(curr_node->ltag, sizeof("[CDATA[") - 1);
192198
ACL_VSTRING_TERMINATE(curr_node->ltag);
193199
}
@@ -197,8 +203,8 @@ static const char *xml_parse_meta_tag(ACL_XML *xml, const char *data)
197203
int ch;
198204

199205
while ((ch = *data) != 0) {
200-
data++;
201-
if (IS_SPACE(ch) || ch == '>') {
206+
#if 0
207+
if (IS_SPACE(ch) || ch == '>' || ch == ']') {
202208
if (IS_CDATA(STR(xml->curr_node->ltag))) {
203209
cdata_prepare(xml->curr_node);
204210
ADDCH(xml->curr_node->text, ch);
@@ -208,6 +214,22 @@ static const char *xml_parse_meta_tag(ACL_XML *xml, const char *data)
208214
xml->curr_node->status = ACL_XML_S_MTXT;
209215
break;
210216
}
217+
#else
218+
if (LEN(xml->curr_node->ltag) >= CDATA_S
219+
&& IS_CDATA(STR(xml->curr_node->ltag)))
220+
{
221+
cdata_prepare(xml->curr_node);
222+
xml->curr_node->status = ACL_XML_S_CDATA;
223+
xml->curr_node->flag |= ACL_XML_F_CDATA;
224+
break;
225+
} else if (IS_SPACE(ch) || ch == '>') {
226+
xml->curr_node->status = ACL_XML_S_MTXT;
227+
data++;
228+
break;
229+
}
230+
#endif
231+
data++;
232+
211233
ADDCH(xml->curr_node->ltag, ch);
212234
}
213235

lib_acl_cpp/changes.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
�޸���ʷ�б���
22

33
-----------------------------------------------------------------------
4+
393) 2015.12.28
5+
393.1) bugfix: �� xml1, xml2 �еĺ��� getFirstElementByTag �ڲ�û���ж� NULL
6+
393.2) bugfix: ȡ���� http_request ���е� acl_assert(client_) �����ж�
7+
8+
392.1) 2015.12.25
9+
392.1) bugfix: dbuf_guard ��Ӧ��ֹ���ÿ����������ڵ��� create �IJ����������
10+
dbuf_guard ������Ϊ�����������⣬�磺
11+
class myobj : public acl::dbuf_obj
12+
{
13+
public:
14+
myobj(acl::dbuf_guard& dbuf) : dbuf_(dbuf) {}
15+
~myobj(void) {}
16+
};
17+
18+
acl::dbuf_guard dbuf;
19+
myobj* obj = dbuf.create<myobj, acl::dbuf_guard>(dbuf);
20+
21+
��Ȼ myobj ���캯������һ�����ã�����Ȼ���� create ʱ�γ����ÿ����������Ӷ�
22+
����� dbuf �ڵĻ������������ͷţ����Խ����ʽ�ǽ�ֹ dbuf_guard �����ÿ���
23+
424
391.1) 2015.12.22
525
391.1) compile: polarssl_io.cpp �н� sys_read_ready ����Ϊ read_ready
626

lib_acl_cpp/include/acl_cpp/stdlib/dbuf_pool.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@ class ACL_CPP_API dbuf_guard
499499

500500
// 扩充 objs_ 数组对象的空间
501501
void extend_objs();
502+
503+
// 禁止引用拷贝
504+
dbuf_guard(dbuf_guard&) {}
502505
};
503506

504507
/**
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
base_path = ../../..
2+
include ../../Makefile.in
3+
PROG = socket_client

0 commit comments

Comments
 (0)