add http fast quit
This commit is contained in:
parent
8e1970be49
commit
54f8a816b5
|
@ -32,6 +32,7 @@ typedef struct SHttpModule {
|
||||||
uv_loop_t* loop;
|
uv_loop_t* loop;
|
||||||
SAsyncPool* asyncPool;
|
SAsyncPool* asyncPool;
|
||||||
TdThread thread;
|
TdThread thread;
|
||||||
|
int8_t quit;
|
||||||
} SHttpModule;
|
} SHttpModule;
|
||||||
|
|
||||||
typedef struct SHttpMsg {
|
typedef struct SHttpMsg {
|
||||||
|
@ -186,6 +187,27 @@ static void httpDestroyMsg(SHttpMsg* msg) {
|
||||||
taosMemoryFree(msg->cont);
|
taosMemoryFree(msg->cont);
|
||||||
taosMemoryFree(msg);
|
taosMemoryFree(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void httpMayDiscardMsg(SHttpModule* http, SAsyncItem* item) {
|
||||||
|
SHttpMsg *msg = NULL, *quitMsg = NULL;
|
||||||
|
if (atomic_load_8(&http->quit) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!QUEUE_IS_EMPTY(&item->qmsg)) {
|
||||||
|
queue* h = QUEUE_HEAD(&item->qmsg);
|
||||||
|
QUEUE_REMOVE(h);
|
||||||
|
msg = QUEUE_DATA(h, SHttpMsg, q);
|
||||||
|
if (!msg->quit) {
|
||||||
|
httpDestroyMsg(msg);
|
||||||
|
} else {
|
||||||
|
quitMsg = msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (quitMsg != NULL) {
|
||||||
|
QUEUE_PUSH(&item->qmsg, &quitMsg->q);
|
||||||
|
}
|
||||||
|
}
|
||||||
static void httpAsyncCb(uv_async_t* handle) {
|
static void httpAsyncCb(uv_async_t* handle) {
|
||||||
SAsyncItem* item = handle->data;
|
SAsyncItem* item = handle->data;
|
||||||
SHttpModule* http = item->pThrd;
|
SHttpModule* http = item->pThrd;
|
||||||
|
@ -194,6 +216,8 @@ static void httpAsyncCb(uv_async_t* handle) {
|
||||||
|
|
||||||
queue wq;
|
queue wq;
|
||||||
taosThreadMutexLock(&item->mtx);
|
taosThreadMutexLock(&item->mtx);
|
||||||
|
httpMayDiscardMsg(http, item);
|
||||||
|
|
||||||
QUEUE_MOVE(&item->qmsg, &wq);
|
QUEUE_MOVE(&item->qmsg, &wq);
|
||||||
taosThreadMutexUnlock(&item->mtx);
|
taosThreadMutexUnlock(&item->mtx);
|
||||||
|
|
||||||
|
@ -466,6 +490,10 @@ void transHttpEnvDestroy() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SHttpModule* load = taosAcquireRef(httpRefMgt, httpRef);
|
SHttpModule* load = taosAcquireRef(httpRefMgt, httpRef);
|
||||||
|
if (load == NULL) return;
|
||||||
|
|
||||||
|
atomic_store_8(&load->quit, 1);
|
||||||
|
|
||||||
httpSendQuit();
|
httpSendQuit();
|
||||||
taosThreadJoin(load->thread, NULL);
|
taosThreadJoin(load->thread, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue