Blocking code for Windows Pipes.

Jouni Malinen jkmaline at cc.hut.fi
Sat Aug 26 18:07:15 EDT 2006


On Wed, Aug 23, 2006 at 03:25:32PM -0700, George S. Lockwood wrote:

> And here is hopefully my last finding...I'm finding that the following
> code burns up 100% resouces until it pending finds something when it
> peeks, the a msg is read and processed.

wpa_ctrl_pending() does not block, so if you call it in while(true)
loop, you have a busy loop.. The current wpa_gui implementation uses a
periodic poll routine to check whether there are any pending events and
will process them. In other words, it does not keep a separate thread
polling for new messages. If you want to use a separate thread, you
could probably just block on wpa_ctrl_recv().

> the while(true) keeps the thread running, so doesn't the pending call
> to peek need to block in some way??

> 		while( wpa_ctrl_pending( pThis->m_pWpa_ctrlMonitor ) ) //monitor_conn

wpa_ctrl_pending() can return -1 to indicate and error, so this should
be wpa_ctrl_pending() > 0.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the HostAP mailing list