Skip to content

Commit 423ffe1

Browse files
committed
修复一处内存可能的泄露
1 parent 047934f commit 423ffe1

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎kbe/src/lib/entitydef/property.cpp‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,12 @@ PyObject* FixedDictDescription::onSetValue(PyObject* parentObj, PyObject* value)
237237
if(static_cast<FixedDictType*>(dataType_)->isSameType(value))
238238
{
239239
FixedDictType* dataType = static_cast<FixedDictType*>(this->getDataType());
240-
return PropertyDescription::onSetValue(parentObj, dataType->createNewFromObj(value));
240+
241+
PyObject* pyobj = dataType->createNewFromObj(value);
242+
PropertyDescription::onSetValue(parentObj, pyobj);
243+
244+
Py_DECREF(pyobj);
245+
return pyobj;
241246
}
242247

243248
return NULL;
@@ -285,7 +290,11 @@ PyObject* ArrayDescription::onSetValue(PyObject* parentObj, PyObject* value)
285290
if(static_cast<FixedArrayType*>(dataType_)->isSameType(value))
286291
{
287292
FixedArrayType* dataType = static_cast<FixedArrayType*>(this->getDataType());
288-
return PropertyDescription::onSetValue(parentObj, dataType->createNewFromObj(value));
293+
PyObject* pyobj = dataType->createNewFromObj(value);
294+
PropertyDescription::onSetValue(parentObj, pyobj);
295+
296+
Py_DECREF(pyobj);
297+
return pyobj;
289298
}
290299

291300
return NULL;

‎kbe/src/lib/server/serverapp.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ void ServerApp::reqCloseServer(Mercury::Channel* pChannel, MemoryStream& s)
431431

432432
Mercury::Bundle::ObjPool().reclaimObject(pBundle);
433433

434-
this->getMainDispatcher().breakProcessing();
434+
this->shutDown();
435435
}
436436

437437
//-------------------------------------------------------------------------------------

‎kbe/src/lib/thread/threadpool.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ void ThreadPool::destroy()
176176

177177
THREAD_MUTEX_LOCK(threadStateList_mutex_);
178178

179+
KBEngine::sleep(100);
180+
179181
std::list<TPThread*>::iterator itr = allThreadList_.begin();
180182
for(; itr != allThreadList_.end(); itr++)
181183
{

‎kbe/src/server/tools/bots/bots.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void Bots::reqCloseServer(Mercury::Channel* pChannel, MemoryStream& s)
274274

275275
Mercury::Bundle::ObjPool().reclaimObject(pBundle);
276276

277-
this->getMainDispatcher().breakProcessing();
277+
this->shutDown();
278278
}
279279

280280
//-------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)