www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: internal poll doesn't handle orderly shut down (read/recv returns 0 bytes) = 100% CPU

internal poll doesn't handle orderly shut down (read/recv returns 0 bytes) = 100% CPU

From: Pavel Strashkin <pavel.strashkin_at_gmail.com>
Date: Mon, 3 Oct 2011 10:21:11 -0700

Hello guys,

I'm working with libssh2 (the latest stable build) using Net::SSH2
Perl binding. It uses internal libssh2 poll helper with a 250ms
timeout. When orderly shut down is occurred (open connection, run some
long-running task, kill/stop/whatever ssh on the server while the task
is running), poll helper starts to consume all available CPU. I've
reviewed the code and found that there is no check for return value of
read/recv function when you're reading from channel (not session).
When zero bytes are read - session should be marked as closed or sort
of.
As result it does as much do/while iterations as it can within N
timeout. In a documentation i saw that you're going to deprecate that
poll helpers, but right now it's still in use and we should fix as
long as we can.

Thank you for the great library!
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-10-03

the libssh2 team