Subject: Re: BLOCK_ADJUST

Re: BLOCK_ADJUST

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 28 Apr 2009 12:42:16 +0200 (CEST)

On Tue, 28 Apr 2009, double wrote:

> I am re-writing my code using non-blocking sockets. The demos check the
> returncode for "LIBSSH2_ERROR_EAGAIN", but most of the libssh2 functions use
> the "BLOCK_ADJUST()" macro.

Let's not mix apples and oranges here.

First: LIBSSH2_ERROR_EAGAIN is a return code lots of libssh2 functions can
return when used in non-blocking mode. I would expect that most applications
would check for that situation.

Then: the "BLOCK_ADJUST()" macro is code used internally by libssh2, but it
basically does nothing in the non-blocking case but is only a way to provide
the blocking behavior when that has been activated.

> Is it still necessary to check the returncode for EAGAIN? If yes, is there a
> list of dangerous functions?

"dangerous" ?

All functions should be documented clearly in regards to what they return so
if things are done right you just read the man pages for the functions you
use.

But yes, the list of functions that may return EAGAIN (or in some cases NULL
due to an EAGAIN situation) is this:

libssh2_channel_close
libssh2_channel_direct_tcpip_ex
libssh2_channel_flush_ex
libssh2_channel_forward_accept
libssh2_channel_forward_cancel
libssh2_channel_forward_listen_ex
libssh2_channel_free
libssh2_channel_handle_extended_data2
libssh2_channel_handle_extended_data
libssh2_channel_open_ex
libssh2_channel_process_startup
libssh2_channel_read_ex
libssh2_channel_receive_window_adjust
libssh2_channel_receive_window_adjust2
libssh2_channel_request_pty_ex
libssh2_channel_request_pty_size_ex
libssh2_channel_send_eof
libssh2_channel_setenv_ex
libssh2_channel_wait_closed
libssh2_channel_wait_eof
libssh2_channel_write_ex
libssh2_channel_x11_req_ex
libssh2_session_disconnect_ex
libssh2_session_free
libssh2_session_startup
libssh2_sftp_close_handle
libssh2_sftp_fstat_ex
libssh2_sftp_init
libssh2_sftp_mkdir_ex
libssh2_sftp_open_ex
libssh2_sftp_read
libssh2_sftp_readdir_ex
libssh2_sftp_rename_ex
libssh2_sftp_rmdir_ex
libssh2_sftp_shutdown
libssh2_sftp_stat_ex
libssh2_sftp_symlink_ex
libssh2_sftp_unlink_ex
libssh2_sftp_write
libssh2_userauth_password_ex
libssh2_userauth_hostbased_fromfile_ex
libssh2_userauth_list
libssh2_userauth_publickey_fromfile_ex
libssh2_userauth_keyboard_interactive_ex

-- 
  / daniel.haxx.se
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-04-28