Hallo.

I've been experimenting with ssh2_exec.c, and while reading the
mailing list "sftp functions leaking memory?" thread, I realized this
example may suffer from the same problem.

On line 142, we've got this:
---
    /* tell libssh2 we want it all done non-blocking */
    libssh2_session_set_blocking(session, 0);
---

Then, on the "shutdown" tag, we've got this:
---
shutdown:

    libssh2_session_disconnect(session,

                               "Normal Shutdown, Thank you for playing");
    libssh2_session_free(session);
---

AFAICT, blocking is still off, so shutdown should be like this:
---
shutdown:

    while (libssh2_session_disconnect(session, "Normal Shutdown, Thank
you for playing") == LIBSSH2_ERROR_EAGAIN)
              ;

    while (libssh2_session_free(session) == LIBSSH2_ERROR_EAGAIN)
              ;
---

I've added no error cheking. Looking at session_disconnect() in
session.c, I was left with the impression that it only returns an
error if description (reason for disconnection) length > 256.
Otherwise, it always returns either LIBSSH2_ERROR_EAGAIN or 0.

Could you pls confirm if my reasoning is correct, so I may submit a
patch for this example?

Thanks.
Paulo Caetano
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to