Skip to content

Commit bb21d64

Browse files
committed
漏掉一处异常时未释放内存的问题
1 parent 3de59ac commit bb21d64

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

kbe/src/lib/server/components.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ int Components::connectComponent(COMPONENT_TYPE componentType, int32 uid, COMPON
309309
pComponentInfos->pChannel->c_str()));
310310

311311
pComponentInfos->pChannel->destroy();
312+
313+
314+
// 此时不可强制释放内存,destroy中已经对其减引用
315+
// SAFE_RELEASE(pComponentInfos->pChannel);
312316
pComponentInfos->pChannel = NULL;
313317
return -1;
314318
}
@@ -389,6 +393,7 @@ int Components::connectComponent(COMPONENT_TYPE componentType, int32 uid, COMPON
389393
ERROR_MSG(fmt::format("Components::connectComponent: connect({}) is failed! {}.\n",
390394
pComponentInfos->pIntAddr->c_str(), kbe_strerror()));
391395

396+
delete pEndpoint;
392397
return -1;
393398
}
394399

@@ -639,7 +644,8 @@ bool Components::checkComponentPortUsable(const Components::ComponentInfos* info
639644
int selgot = select(epListen+1, &fds, NULL, NULL, &tv);
640645
if(selgot == 0)
641646
{
642-
return true; // 超时可能对方繁忙
647+
// 超时, 可能对方繁忙
648+
return true;
643649
}
644650
else if(selgot == -1)
645651
{

0 commit comments

Comments
 (0)