[Libssh] [PATCH 1/2] Add a generic way to handle sockets asynchronously.

Andreas Schneider mail at cynapses.org
Thu Jun 25 19:32:32 CEST 2009


On Wednesday 24 June 2009 16:44:31 Aleksandar Kanchev wrote:
> It's based on poll objects, each of which store a socket, it's events and a
> callback, which gets called whenever an event is set. The poll objects are
> attached to a poll context, which should be allocated on per thread basis.
>
> Polling the poll context will poll all the attached poll objects and call
> their callbacks (handlers) if any of the socket events are set. This should
> be done within the main loop of an application.
>
> This is intended as a ground work for making libssh asynchronous.

Hi Aleksandar,

thanks for the patch!

>
> Signed-off-by: Aleksandar Kanchev <aleksandar.kanchev at googlemail.com>
> ---
>  include/libssh/libssh.h |  163 ++++++++++++++++++++++++++++++++++
>  include/libssh/priv.h   |    8 --
>  libssh/poll.c           |  226
> +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 389
> insertions(+), 8 deletions(-)
>
> diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
> index 18d42c7..4f9ffd1 100644
> --- a/include/libssh/libssh.h
> +++ b/include/libssh/libssh.h
> @@ -375,6 +375,169 @@ char *ssh_userauth_kbdint_getprompt(SSH_SESSION
> *session, unsigned int i, char * int
> ssh_userauth_kbdint_setanswer(SSH_SESSION *session, unsigned int i, const
> char *answer);
>
> +/* poll.c */
> +#define POLLIN    0x001  /* There is data to read.  */
> +#define POLLPRI   0x002  /* There is urgent data to read.  */
> +#define POLLOUT   0x004  /* Writing now will not block.  */
> +
> +#define POLLERR   0x008  /* Error condition.  */
> +#define POLLHUP   0x010  /* Hung up.  */
> +#define POLLNVAL  0x020  /* Invalid polling request.  */
> +

Why do you move this here? These definitions are only set if poll.h wasn't 
found, normally on windows. This should conflict with poll.h. If there is 
something wrong please tell me :)

Cheers,

	-- andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://www.cerkinfo.be/pipermail/libssh/attachments/20090625/5a73a8e5/attachment.pgp 


More information about the Libssh mailing list