提交 4346feb7 编写于 作者: L laiguizhong

修改conntect为connect

Signed-off-by: Nlaiguizhong <laiguizhong@huawei.com>
上级 7815064b
......@@ -93,7 +93,7 @@ static int SendMessage(LoopHandle loop, TaskHandle task, const char *message)
return 0;
}
static int CmdOnIncommingConntect(const LoopHandle loop, const TaskHandle server)
static int CmdOnIncommingConnect(const LoopHandle loop, const TaskHandle server)
{
TaskHandle client = NULL;
LE_StreamInfo info = {};
......@@ -128,7 +128,7 @@ void CmdServiceInit(const char *socketPath, CallbackControlFdProcess func)
info.socketId = -1;
info.baseInfo.close = NULL;
info.disConnectComplete = NULL;
info.incommingConntect = CmdOnIncommingConntect;
info.incommingConnect = CmdOnIncommingConnect;
info.sendMessageComplete = NULL;
info.recvMessage = NULL;
g_controlFdFunc = func;
......
......@@ -93,17 +93,17 @@ typedef struct {
#define TASK_SERVER (0x01 << 16)
#define TASK_CONNECT (0x02 << 16)
#define TASK_TEST (0x01 << 24)
typedef void (*LE_DisConntectComplete)(const TaskHandle client);
typedef void (*LE_ConntectComplete)(const TaskHandle client);
typedef void (*LE_DisConnectComplete)(const TaskHandle client);
typedef void (*LE_ConnectComplete)(const TaskHandle client);
typedef void (*LE_SendMessageComplete)(const TaskHandle taskHandle, BufferHandle handle);
typedef void (*LE_RecvMessage)(const TaskHandle taskHandle, const uint8_t *buffer, uint32_t buffLen);
typedef int (*LE_IncommingConntect)(const LoopHandle loopHandle, const TaskHandle serverTask);
typedef int (*LE_IncommingConnect)(const LoopHandle loopHandle, const TaskHandle serverTask);
typedef struct {
LE_BaseInfo baseInfo;
char *server;
int socketId;
LE_DisConntectComplete disConnectComplete;
LE_IncommingConntect incommingConntect;
LE_DisConnectComplete disConnectComplete;
LE_IncommingConnect incommingConnect;
LE_SendMessageComplete sendMessageComplete;
LE_RecvMessage recvMessage;
} LE_StreamServerInfo;
......@@ -111,8 +111,8 @@ typedef struct {
typedef struct {
LE_BaseInfo baseInfo;
char *server;
LE_DisConntectComplete disConnectComplete;
LE_ConntectComplete connectComplete;
LE_DisConnectComplete disConnectComplete;
LE_ConnectComplete connectComplete;
LE_SendMessageComplete sendMessageComplete;
LE_RecvMessage recvMessage;
} LE_StreamInfo;
......
......@@ -141,9 +141,9 @@ static LE_STATUS HandleServerEvent_(const LoopHandle loopHandle, const TaskHandl
return LE_FAILURE;
}
StreamServerTask *server = (StreamServerTask *)serverTask;
LE_ONLY_CHECK(server->incommingConntect != NULL, return LE_SUCCESS);
LE_ONLY_CHECK(server->incommingConnect != NULL, return LE_SUCCESS);
int ret = server->incommingConntect(loopHandle, serverTask);
int ret = server->incommingConnect(loopHandle, serverTask);
if (ret != LE_SUCCESS) {
LE_LOGE("HandleServerEvent_ fd %d do not accept socket", GetSocketFd(serverTask));
}
......@@ -157,8 +157,8 @@ LE_STATUS LE_CreateStreamServer(const LoopHandle loopHandle,
{
LE_CHECK(loopHandle != NULL && taskHandle != NULL && info != NULL, return LE_INVALID_PARAM, "Invalid parameters");
LE_CHECK(info->server != NULL, return LE_INVALID_PARAM, "Invalid parameters server");
LE_CHECK(info->incommingConntect != NULL, return LE_INVALID_PARAM,
"Invalid parameters incommingConntect %s", info->server);
LE_CHECK(info->incommingConnect != NULL, return LE_INVALID_PARAM,
"Invalid parameters incommingConnect %s", info->server);
int fd = info->socketId;
if (info->socketId <= 0) {
......@@ -173,7 +173,7 @@ LE_STATUS LE_CreateStreamServer(const LoopHandle loopHandle,
return LE_NO_MEMORY, "Failed to create task");
task->base.handleEvent = HandleServerEvent_;
task->base.innerClose = HandleStreamTaskClose_;
task->incommingConntect = info->incommingConntect;
task->incommingConnect = info->incommingConnect;
loop->addEvent(loop, (const BaseTask *)task, Event_Read);
int ret = memcpy_s(task->server, strlen(info->server) + 1, info->server, strlen(info->server) + 1);
LE_CHECK(ret == 0, return LE_FAILURE, "Failed to copy server name %s", info->server);
......
......@@ -72,7 +72,7 @@ typedef struct LiteTask_ {
typedef struct {
BaseTask base;
LE_IncommingConntect incommingConntect;
LE_IncommingConnect incommingConnect;
char server[0];
} StreamServerTask;
......@@ -91,13 +91,13 @@ typedef struct {
StreamServerTask *serverTask;
LE_SendMessageComplete sendMessageComplete;
LE_RecvMessage recvMessage;
LE_DisConntectComplete disConnectComplete;
LE_DisConnectComplete disConnectComplete;
} StreamConnectTask;
typedef struct {
StreamTask stream;
LE_DisConntectComplete disConnectComplete;
LE_ConntectComplete connectComplete;
LE_DisConnectComplete disConnectComplete;
LE_ConnectComplete connectComplete;
LE_SendMessageComplete sendMessageComplete;
LE_RecvMessage recvMessage;
uint32_t connected : 1;
......
......@@ -20,7 +20,7 @@
#include "param_utils.h"
#include "securec.h"
int ConntectServer(int fd, const char *servername)
int ConnectServer(int fd, const char *servername)
{
PARAM_CHECK(fd >= 0, return -1, "Invalid fd %d", fd);
int opt = 1;
......@@ -36,7 +36,7 @@ int ConntectServer(int fd, const char *servername)
int len = offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path);
ret = connect(fd, (struct sockaddr *)&addr, len);
PARAM_CHECK(ret != -1, return -1, "Failed to connect server %s %d", servername, errno);
PARAM_LOGV("ConntectServer %s success", servername);
PARAM_LOGV("ConnectServer %s success", servername);
return 0;
}
......
......@@ -75,7 +75,7 @@ typedef int (*RecvMessage)(const ParamTaskPtr stream, const ParamMessage *msg);
typedef struct {
uint32_t flags;
char *server;
LE_IncommingConntect incomingConnect;
LE_IncommingConnect incomingConnect;
RecvMessage recvMessage;
LE_Close close;
} ParamStreamInfo;
......@@ -97,7 +97,7 @@ int FillParamMsgContent(const ParamMessage *request, uint32_t *start, int type,
ParamMsgContent *GetNextContent(const ParamMessage *reqest, uint32_t *offset);
ParamMessage *CreateParamMessage(int type, const char *name, uint32_t msgSize);
int ConntectServer(int fd, const char *servername);
int ConnectServer(int fd, const char *servername);
#ifdef STARTUP_INIT_TEST
int ProcessMessage(const ParamTaskPtr worker, const ParamMessage *msg);
......
......@@ -52,7 +52,7 @@ int ParamServerCreate(ParamTaskPtr *stream, const ParamStreamInfo *streamInfo)
info.baseInfo.flags = TASK_STREAM | TASK_PIPE | TASK_SERVER;
info.server = streamInfo->server;
info.baseInfo.close = streamInfo->close;
info.incommingConntect = streamInfo->incomingConnect;
info.incommingConnect = streamInfo->incomingConnect;
return LE_CreateStreamServer(LE_GetDefaultLoop(), stream, &info);
}
......
......@@ -112,7 +112,7 @@ static int GetClientSocket(int timeout)
time.tv_usec = 0;
int clientFd = socket(AF_UNIX, SOCK_STREAM, 0);
PARAM_CHECK(clientFd >= 0, return -1, "Failed to create socket");
int ret = ConntectServer(clientFd, CLIENT_PIPE_NAME);
int ret = ConnectServer(clientFd, CLIENT_PIPE_NAME);
if (ret == 0) {
setsockopt(clientFd, SOL_SOCKET, SO_SNDTIMEO, (char *)&time, sizeof(struct timeval));
setsockopt(clientFd, SOL_SOCKET, SO_RCVTIMEO, (char *)&time, sizeof(struct timeval));
......
......@@ -296,7 +296,7 @@ int WatcherManager::GetServerFd(bool retry)
serverFd_ = socket(PF_UNIX, SOCK_STREAM, 0);
int flags = fcntl(serverFd_, F_GETFL, 0);
(void)fcntl(serverFd_, F_SETFL, flags & ~O_NONBLOCK);
ret = ConntectServer(serverFd_, CLIENT_PIPE_NAME);
ret = ConnectServer(serverFd_, CLIENT_PIPE_NAME);
if (ret == 0) {
break;
}
......
......@@ -163,7 +163,7 @@ public:
info.baseInfo.flags = TASK_STREAM | TASK_PIPE | TASK_SERVER | TASK_TEST;
info.server = (char *)"/data/testpipe";
info.baseInfo.close = OnClose;
info.incommingConntect = IncomingConnect;
info.incommingConnect = IncomingConnect;
LE_CreateStreamServer(LE_GetDefaultLoop(), &serverTask_, &info);
if (serverTask_ == nullptr) {
return;
......@@ -246,7 +246,7 @@ public:
info.baseInfo.flags = TASK_PIPE | TASK_CONNECT | TASK_TEST;
info.server = (char *)"/data/testpipe";
info.baseInfo.close = OnClose;
info.incommingConntect = IncomingConnect;
info.incommingConnect = IncomingConnect;
info.socketId = 1111; // 1111 is test fd
LE_CreateStreamServer(LE_GetDefaultLoop(), &serverTask, &info);
EXPECT_NE(serverTask, nullptr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册