[ofa-general] Re: [PATCH] opensm/console: Fixed osm_console poll to so it won't eat up all CPU when stdin is a pipe

Nicolas Morey Chaisemartin nicolas.morey-chaisemartin at ext.bull.net
Fri Mar 6 00:27:45 PST 2009


Sasha Khapyorsky wrote:
> Hi Nicolas,
> 
> On 16:16 Mon 02 Mar     , Nicolas Morey Chaisemartin wrote:
>> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas.morey-chaisemartin at ext.bull.net>
>> ---
> 
> I guess that below is commit message, right? Assuming so, it should be
> before '---' line.
> 
>> When opensm is called after a pipe to execute a command in the local console, it uses 100% CPU as osm_console poll returns as if there was something to read from stdin where there isn't.
> 
> As far as I understand described usage (echo blah-blah | opensm ....)
> there should be nothing to read after 'echo' finished its job and poll()
> will set POLLHUP revents bit.
> 

You're right. Although my man page says it's for output only, it works.

>> This patch fixes by closing the local console when the end of osm_console function has been reached, meaning poll returned a positive value but actually nothing to read. osm_console will return an error code which will unset the console_init_flag so it won't be reopened.
>>
>> For socket, the osm_console_close is called as it means the socket isn't in a proper state.
> 
> And then what osm_console() will do? Wouldn't it run over fd_in?
> 
Well, maybe it could just kill the current connection (cio_close).

By the way shouldn't the quit_parse function call cio_close instead od osm_console_close.
In the current implementation, calling exit kills the socket so there can be no further connection. 

Nicolas



More information about the general mailing list