未验证 提交 32a91740 编写于 作者: O openharmony_ci 提交者: Gitee

!1189 增加send result

Merge pull request !1189 from cheng_jinsong/timeout
......@@ -76,6 +76,7 @@ BufferHandle LE_CreateBuffer(const LoopHandle loopHandle, uint32_t bufferSize);
void LE_FreeBuffer(const LoopHandle loopHandle, const TaskHandle taskHandle, const BufferHandle handle);
uint8_t *LE_GetBufferInfo(const BufferHandle handle, uint32_t *dataSize, uint32_t *buffSize);
void *LE_GetUserData(const TaskHandle handle);
int32_t LE_GetSendResult(const BufferHandle handle);
typedef void (*LE_Close)(const TaskHandle taskHandle);
typedef struct {
......
......@@ -30,6 +30,7 @@ static LE_STATUS HandleSendMsg_(const LoopHandle loopHandle,
while (buffer) {
int ret = write(GetSocketFd(taskHandle), buffer->data, buffer->dataSize);
LE_LOGV("HandleSendMsg_ fd:%d send data size %d %d", GetSocketFd(taskHandle), buffer->dataSize, ret);
buffer->result = (ret == buffer->dataSize) ? 0 : errno;
if (complete != NULL) {
complete(taskHandle, buffer);
}
......
......@@ -202,4 +202,10 @@ void *LE_GetUserData(TaskHandle handle)
LE_CHECK(handle != NULL, return NULL, "Invalid handle");
BaseTask *stream = (BaseTask *)handle;
return (void *)(((char *)stream) + stream->userDataOffset);
}
int32_t LE_GetSendResult(const BufferHandle handle)
{
LE_CHECK(handle != NULL, return 0, "Invalid handle");
return ((LE_Buffer *)handle)->result;
}
\ No newline at end of file
......@@ -44,6 +44,7 @@ typedef struct {
ListNode node;
uint32_t buffSize;
uint32_t dataSize;
int32_t result;
uint8_t data[0];
} LE_Buffer;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册