提交 85f5d4d5 编写于 作者: S Shengliang Guan

Merge remote-tracking branch 'origin/3.0' into fix/dnode

......@@ -39,7 +39,8 @@ static void idxGenLRUKey(char* buf, const char* path, int32_t blockId) {
}
static int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
if (ctx->type == TFILE) {
assert(len == taosWriteFile(ctx->file.pFile, buf, len));
int nwr = taosWriteFile(ctx->file.pFile, buf, len);
assert(nwr == len);
} else {
memcpy(ctx->mem.buf + ctx->offset, buf, len);
}
......
......@@ -21,6 +21,7 @@
#include "taoserror.h"
#include "tlog.h"
// clang-format on
#define HTTP_RECV_BUF_SIZE 1024
......@@ -29,7 +30,7 @@ typedef struct SHttpClient {
uv_tcp_t tcp;
uv_write_t req;
uv_buf_t* wbuf;
char *rbuf;
char* rbuf;
char* addr;
uint16_t port;
} SHttpClient;
......@@ -130,37 +131,36 @@ static void destroyHttpClient(SHttpClient* cli) {
taosMemoryFree(cli->rbuf);
taosMemoryFree(cli->addr);
taosMemoryFree(cli);
}
static void clientCloseCb(uv_handle_t* handle) {
SHttpClient* cli = handle->data;
destroyHttpClient(cli);
}
static void clientAllocBuffCb(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) {
SHttpClient* cli = handle->data;
buf->base = cli->rbuf;
buf->len = HTTP_RECV_BUF_SIZE;
static void clientAllocBuffCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
SHttpClient* cli = handle->data;
buf->base = cli->rbuf;
buf->len = HTTP_RECV_BUF_SIZE;
}
static void clientRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t *buf) {
SHttpClient* cli = handle->data;
static void clientRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
SHttpClient* cli = handle->data;
if (nread < 0) {
uError("http-report recv error:%s", uv_err_name(nread));
} else {
uTrace("http-report succ to recv %d bytes, just ignore it", nread);
}
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
}
}
static void clientSentCb(uv_write_t* req, int32_t status) {
SHttpClient* cli = req->data;
if (status != 0) {
terrno = TAOS_SYSTEM_ERROR(status);
uError("http-report failed to send data %s", uv_strerror(status));
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
return;
return;
} else {
uTrace("http-report succ to send data");
}
uv_read_start((uv_stream_t *)&cli->tcp, clientAllocBuffCb, clientRecvCb);
uv_read_start((uv_stream_t*)&cli->tcp, clientAllocBuffCb, clientRecvCb);
}
static void clientConnCb(uv_connect_t* req, int32_t status) {
SHttpClient* cli = req->data;
......@@ -212,7 +212,7 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
cli->tcp.data = cli;
cli->req.data = cli;
cli->wbuf = wb;
cli->rbuf = taosMemoryCalloc(1, HTTP_RECV_BUF_SIZE);
cli->rbuf = taosMemoryCalloc(1, HTTP_RECV_BUF_SIZE);
cli->addr = tstrdup(server);
cli->port = port;
......@@ -233,4 +233,3 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
uv_loop_close(loop);
return terrno;
}
// clang-format on
......@@ -906,23 +906,30 @@ static void uvDestroyConn(uv_handle_t* handle) {
}
}
static void uvPipeListenCb(uv_stream_t* handle, int status) {
ASSERT(status == 0);
if (status != 0) {
tError("server failed to init pipe");
return;
}
SServerObj* srv = container_of(handle, SServerObj, pipeListen);
uv_pipe_t* pipe = &(srv->pipe[srv->numOfWorkerReady][0]);
ASSERT(0 == uv_pipe_init(srv->loop, pipe, 1));
ASSERT(0 == uv_accept((uv_stream_t*)&srv->pipeListen, (uv_stream_t*)pipe));
ASSERT(1 == uv_is_readable((uv_stream_t*)pipe));
ASSERT(1 == uv_is_writable((uv_stream_t*)pipe));
ASSERT(0 == uv_is_closing((uv_handle_t*)pipe));
int ret = uv_pipe_init(srv->loop, pipe, 1);
assert(ret == 0);
srv->numOfWorkerReady++;
ret = uv_accept((uv_stream_t*)&srv->pipeListen, (uv_stream_t*)pipe);
assert(ret == 0);
ret = uv_is_readable((uv_stream_t*)pipe);
assert(ret == 1);
// ASSERT(0 == uv_listen((uv_stream_t*)&ctx.send.tcp, 512, uvOnAcceptCb));
ret = uv_is_writable((uv_stream_t*)pipe);
assert(ret == 1);
// r = uv_read_start((uv_stream_t*)&ctx.channel, alloc_cb, read_cb);
// ASSERT(r == 0);
ret = uv_is_closing((uv_handle_t*)pipe);
assert(ret == 0);
srv->numOfWorkerReady++;
}
void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) {
......@@ -937,7 +944,9 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
srv->port = port;
uv_loop_init(srv->loop);
assert(0 == uv_pipe_init(srv->loop, &srv->pipeListen, 0));
int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0);
assert(ret == 0);
#ifdef WINDOWS
char pipeName[64];
snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%p-" PRIu64, taosSafeRand(), GetCurrentProcessId());
......@@ -946,8 +955,11 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08X-" PRIu64, tsTempDir, TD_DIRSEP, taosSafeRand(),
taosGetSelfPthreadId());
#endif
assert(0 == uv_pipe_bind(&srv->pipeListen, pipeName));
assert(0 == uv_listen((uv_stream_t*)&srv->pipeListen, SOMAXCONN, uvPipeListenCb));
ret = uv_pipe_bind(&srv->pipeListen, pipeName);
assert(ret == 0);
ret = uv_listen((uv_stream_t*)&srv->pipeListen, SOMAXCONN, uvPipeListenCb);
assert(ret == 0);
for (int i = 0; i < srv->numOfThreads; i++) {
SWorkThrd* thrd = (SWorkThrd*)taosMemoryCalloc(1, sizeof(SWorkThrd));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册