提交 d73cdd65 编写于 作者: F freemine

1. bugFix: typo in eok.c which results in memory leakage

2. for the sake of SIGALRM used in the base code, add taos_block_sigalrm and so forth
3. TODO: getaddrinfo would block a few unnecessary seconds when host ~ *.local
         better give warning/suggestion message to user, or just bypass getaddrinfo
         and fail the function
上级 0ef43ca3
......@@ -22,6 +22,8 @@
extern "C" {
#endif
#ifdef __APPLE__
enum EPOLL_EVENTS
{
EPOLLIN = 0x001,
......@@ -81,6 +83,8 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout);
int epoll_close(int epfd);
#endif // __APPLE__
#ifdef __cplusplus
}
#endif
......
......@@ -104,6 +104,8 @@ int64_t tsosStr2int64(char *str);
#include "eok.h"
void taos_block_sigalrm(void);
......
......@@ -34,3 +34,16 @@ void taosUninitTimer() {
setitimer(ITIMER_REAL, &tv, NULL);
}
void taos_block_sigalrm(void) {
// since SIGALRM has been used
// consideration: any better solution?
static __thread int already_set = 0;
if (!already_set) {
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGALRM);
pthread_sigmask(SIG_BLOCK, &set, NULL);
already_set = 1;
}
}
......@@ -15,15 +15,11 @@
#include "eok.h"
#include <errno.h>
#include <libgen.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "os.h"
#include <sys/event.h>
#include <sys/socket.h>
#include <unistd.h>
#define LET_IT_BE
#ifdef ENABLE_LOG
#define D(fmt, ...) fprintf(stderr, "%s[%d]%s(): " fmt "\n", basename(__FILE__), __LINE__, __func__, ##__VA_ARGS__)
......@@ -414,6 +410,8 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) {
static struct timespec do_timespec_diff(struct timespec *from, struct timespec *to);
int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) {
taos_block_sigalrm();
int e = 0;
if (!events) {
errno = EINVAL;
......@@ -699,7 +697,7 @@ static void eok_free_ev(ep_over_kq_t *eok, eok_event_t *ev) {
else eok->evs_tail = ev->prev;
ev->prev = NULL;
ev->next = eok->evs_free;
eok->evs_free = ev->next;
eok->evs_free = ev;
eok->evs_count -= 1;
}
......
......@@ -116,6 +116,9 @@ void taosUninitTimer() {
pthread_sigmask(SIG_BLOCK, &set, NULL);
*/
void taosMsleep(int mseconds) {
#ifdef __APPLE__
taos_block_sigalrm();
#endif // __APPLE__
#if 1
usleep(mseconds * 1000);
#else
......@@ -136,6 +139,7 @@ void taosMsleep(int mseconds) {
/* pthread_sigmask(SIG_UNBLOCK, &set, NULL); */
#endif
}
#endif
\ No newline at end of file
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册