DSNetwork的讨论:其中是不是存在问题啊?

msgsnd 2008-03-28 04:08:13
进来有时间,学习了一下DSNetwork,有些疑问:
关于bufferPool中:
1、部分代码没有看懂,我觉得有泄漏,并发现很久以前一个网友的看法与我一样,参见
http://topic.csdn.net/t/20051107/08/4375646.html
内容附在后面
2、我认为这两个变量没有必要存在
LIST_ENTRY m_Buffers ;
LIST_ENTRY m_RequestPool ;
参考MSPool也只是用了一个List,何必增加另外两个。

确实没看懂,有必要讨论一下,明白的人指教一下。


在接受端,使用双缓冲的代码,总感觉不对
CBuffer *CBufferPool::GetBuffer (
IN HANDLE hEvent,
IN DWORD dwTimeout
)
{

if(!IsListEmpty (& m_Buffers)
{
.......
}
else
{
// get a request
pBlockRequest = GetRequestLocked_ () ;
if (pBlockRequest == NULL) {
// memory allocation failure most likely
Unlock_ () ;

return NULL ;
}

// non-signal the event we'll wait on
pBlockRequest -> hEvent = hEvent ;
ResetEvent (pBlockRequest -> hEvent) ;

// insert into tail of request queue
InsertTailList (& m_Request, & pBlockRequest -> ListEntry) ;

// release the lock and wait
Unlock_ () ;
r = WaitForSingleObject (hEvent, dwTimeout) ;// dwTimeout =0

// reacquire the lock
Lock_ () ;

if (r == WAIT_TIMEOUT) {
// might have timed out and blocked on the lock aquisition while
// the BLOCK_REQUEST was being completed on the other side; if
// this is the case, we succeed the call, even though we timed
// out waiting

if (pBlockRequest -> pBuffer == NULL) {

// actual timeout; recycle the BLOCK_REQUEST and punt
RemoveEntryList (& pBlockRequest -> ListEntry) ;
RecycleRequestLocked_ (pBlockRequest) ;
Unlock_ () ;

return NULL ;
}
}

// we have a buffer, whether or not we timed out in the process of
// getting it

// we'll return this
pBuffer = pBlockRequest -> pBuffer ; //这个pBlockRequest -> pBuffer我认为始终为 NULL

// recycle the request struct
RecycleRequestLocked_ (pBlockRequest) ;
}
}



CBufferPool::Recycle (
IN CBuffer * pBuffer
)
{
LIST_ENTRY * pListEntry ;
BLOCK_REQUEST * pBlockRequest ;

Lock_ () ;

// check if there are queued outstanding requests
if (!IsListEmpty (& m_Request))
{
pListEntry = RemoveHeadList (& m_RequestPool) ; ///??????????
pBlockRequest = CONTAINING_RECORD (pListEntry, BLOCK_REQUEST, ListEntry) ;

// set the buffer and addref (BLOCK_REQUEST's)
pBlockRequest -> pBuffer = pBuffer ; //我觉得程序将无法访问pBlockRequest
pBuffer -> AddRef () ;

// signal; do this last
SetEvent (pBlockRequest -> hEvent) ;
}
}
...全文
135 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
msgsnd 2008-04-08
  • 打赏
  • 举报
回复
讨论的人不少,但是认真看的不多
msgsnd 2008-04-01
  • 打赏
  • 举报
回复
其实我认真的跟踪过程序的运行,发现:
1、有疑问的两个地方都走不到
2、存在大量的丢包问题
可能我的一些参数设置的问题,不能完全发现问题。
lserlohn 2008-03-31
  • 打赏
  • 举报
回复
我没特别认真看过,不少人认为这个例子写得不太好
msgsnd 2008-03-31
  • 打赏
  • 举报
回复
是不是没有几个人认真的看过这个sample啊?

2,554

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧