mirror of
https://gitee.com/openharmony/startup_init
synced 2024-11-23 16:20:00 +00:00
add fd
Change-Id: I539d3602c0081b6b34cfc6a49a59d6e3bcaacd1b Signed-off-by: yanghao <yanghao236@huawei.com>
This commit is contained in:
parent
6068bcbabb
commit
f989306062
@ -101,6 +101,7 @@ 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_IncommingConnect)(const LoopHandle loopHandle, const TaskHandle serverTask);
|
||||
typedef int (*LE_HandleRecvMsg)(const TaskHandle taskHandle, uint8_t* buffer, int bufferSize, int flags);
|
||||
typedef struct {
|
||||
LE_BaseInfo baseInfo;
|
||||
char *server;
|
||||
@ -118,6 +119,7 @@ typedef struct {
|
||||
LE_ConnectComplete connectComplete;
|
||||
LE_SendMessageComplete sendMessageComplete;
|
||||
LE_RecvMessage recvMessage;
|
||||
LE_HandleRecvMsg handleRecvMsg;
|
||||
} LE_StreamInfo;
|
||||
|
||||
LE_STATUS LE_CreateStreamServer(const LoopHandle loopHandle,
|
||||
|
@ -55,9 +55,14 @@ static LE_STATUS HandleRecvMsg_(const LoopHandle loopHandle,
|
||||
{
|
||||
LE_STATUS status = LE_SUCCESS;
|
||||
LE_Buffer *buffer = CreateBuffer(LOOP_DEFAULT_BUFFER);
|
||||
StreamConnectTask *stream = (StreamConnectTask *)taskHandle;
|
||||
int readLen = 0;
|
||||
while (1) {
|
||||
readLen = recv(GetSocketFd(taskHandle), buffer->data, LOOP_DEFAULT_BUFFER, 0);
|
||||
if (stream->handleRecvMsg != NULL) {
|
||||
readLen = stream->handleRecvMsg(taskHandle, buffer->data, LOOP_DEFAULT_BUFFER, 0);
|
||||
} else {
|
||||
readLen = recv(GetSocketFd(taskHandle), buffer->data, LOOP_DEFAULT_BUFFER, 0);
|
||||
}
|
||||
LE_LOGV("HandleRecvMsg fd:%d read msg len %d", GetSocketFd(taskHandle), readLen);
|
||||
if (readLen < 0) {
|
||||
if (errno == EINTR || errno == EWOULDBLOCK || errno == EAGAIN) {
|
||||
@ -278,6 +283,7 @@ LE_STATUS LE_AcceptStreamClient(const LoopHandle loopHandle, const TaskHandle se
|
||||
task->sendMessageComplete = info->sendMessageComplete;
|
||||
task->recvMessage = info->recvMessage;
|
||||
task->serverTask = (StreamServerTask *)server;
|
||||
task->handleRecvMsg = info->handleRecvMsg;
|
||||
OH_ListInit(&task->stream.buffHead);
|
||||
LoopMutexInit(&task->stream.mutex);
|
||||
if ((info->baseInfo.flags & TASK_TEST) != TASK_TEST) {
|
||||
|
@ -97,6 +97,7 @@ typedef struct {
|
||||
LE_SendMessageComplete sendMessageComplete;
|
||||
LE_RecvMessage recvMessage;
|
||||
LE_DisConnectComplete disConnectComplete;
|
||||
LE_HandleRecvMsg handleRecvMsg;
|
||||
} StreamConnectTask;
|
||||
|
||||
typedef struct {
|
||||
|
Loading…
Reference in New Issue
Block a user