[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 0.5.5 Hang on sftp_new calling channel_open()


This ended up being a misnomer since cmake-gui didn't set the environment
up correctly.  I ended up getting a clean build of 0.5.5 which works
great.  I thought I had already sent an email explaining this.

I can try rc2 if you want.

Kevin
On Nov 22, 2013 7:02 AM, "Ashish Mangla" <Ashish.Mangla@xxxxxxxxxxxxxx>
wrote:

>
>
>
>  Sent from Samsung Note II
>
>
> -------- Original message --------
> From: Andreas Schneider <asn@xxxxxxxxxxxxxx>
> Date: 22/11/2013 17:04 (GMT+05:30)
> To: libssh@xxxxxxxxxx
> Cc: Kevin Lambert <klambert@xxxxxxxxx>
> Subject: Re: 0.5.5 Hang on sftp_new calling channel_open()
>
>
>  On Tuesday 05 November 2013 11:31:00 Kevin Lambert wrote:
> > I have a Digi WR21 modem that if I attempt to make an sftp_new() call
> while
> > the modem is still booting I get a hang in channel_open() because the
> > channel->state never switches from SSH_CHANNEL_STATE_NOT_OPEN and there
> > isn't a check on the session timeout in:
> >
> >   /* Todo: fix this into a correct loop */
> >
> >   /* wait until channel is opened by server */
> >
> >   while(channel->state == SSH_CHANNEL_STATE_NOT_OPEN){
> >
> >     ssh_handle_packets(session,-1);
> >
> >   }
>
> Can you please try libssh 0.6.0rc2?
>
> >
> >
> > So the the open call is stuck in that while loop without a way to break
> out.
> > Is there any reason why a check cant be added against the
> session->timeout
> > parameter like so:
> >
> >
> >
> > static int channel_open(ssh_channel channel, const char *type_c, int
> window,
> >
> >     int maxpacket, ssh_buffer payload) {
> >
> >   ssh_session session = channel->session;
> >
> >   ssh_string type = NULL;
> >
> >   int err=SSH_ERROR;
> >
> >   int useTimeout = (session->timeout + (1000 * session->timeout_usec)) >
> 0;
> >
> >   time_t timeout = time(NULL) + session->timeout + (1000 *
> > session->timeout_usec);
> >
> >
> >
> >   enter_function();
> >
> >   channel->local_channel = ssh_channel_new_id(session);
> >
> >   channel->local_maxpacket = maxpacket;
> >
> >   channel->local_window = window;
> >
> >
> >
> >   ssh_log(session, SSH_LOG_PROTOCOL,
> >
> >       "Creating a channel %d with %d window and %d max packet",
> >
> >       channel->local_channel, window, maxpacket);
> >
> >
> >
> >   type = ssh_string_from_char(type_c);
> >
> >   if (type == NULL) {
> >
> >     ssh_set_error_oom(session);
> >
> >     leave_function();
> >
> >     return err;
> >
> >   }
> >
> >
> >
> >   if (buffer_add_u8(session->out_buffer, SSH2_MSG_CHANNEL_OPEN) < 0 ||
> >
> >       buffer_add_ssh_string(session->out_buffer,type) < 0 ||
> >
> >       buffer_add_u32(session->out_buffer, htonl(channel->local_channel))
> < 0
> >
> >
> >       buffer_add_u32(session->out_buffer, htonl(channel->local_window))
> < 0
> >
> >
> >       buffer_add_u32(session->out_buffer,
> htonl(channel->local_maxpacket)) <
> > 0) {
> >
> >     ssh_set_error_oom(session);
> >
> >     ssh_string_free(type);
> >
> >     leave_function();
> >
> >     return err;
> >
> >   }
> >
> >
> >
> >   ssh_string_free(type);
> >
> >
> >
> >   if (payload != NULL) {
> >
> >     if (buffer_add_buffer(session->out_buffer, payload) < 0) {
> >
> >       ssh_set_error_oom(session);
> >
> >       leave_function();
> >
> >       return err;
> >
> >     }
> >
> >   }
> >
> >
> >
> >   if (packet_send(session) == SSH_ERROR) {
> >
> >     leave_function();
> >
> >     return err;
> >
> >   }
> >
> >
> >
> >   ssh_log(session, SSH_LOG_PACKET,
> >
> >       "Sent a SSH_MSG_CHANNEL_OPEN type %s for channel %d",
> >
> >       type_c, channel->local_channel);
> >
> >
> >
> >   /* Todo: fix this into a correct loop */
> >
> >   /* wait until channel is opened by server */
> >
> >   while(channel->state == SSH_CHANNEL_STATE_NOT_OPEN && (!useTimeout ||
> > (useTimeout && (time(NULL) < timeout))) ){
> >
> >     ssh_handle_packets(session,-1);
> >
> >   }
> >
> >   if(channel->state == SSH_CHANNEL_STATE_OPEN)
> >
> >     err=SSH_OK;
> >
> >   leave_function();
> >
> >   return err;
> >
> > }
>
> --
> Andreas Schneider                   GPG-ID: CC014E3D
> www.cryptomilk.org                asn@xxxxxxxxxxxxxx
>
>
>
>

References:
0.5.5 Hang on sftp_new calling channel_open()"Kevin Lambert" <klambert@xxxxxxxxx>
Re: 0.5.5 Hang on sftp_new calling channel_open()Andreas Schneider <asn@xxxxxxxxxxxxxx>
Re: 0.5.5 Hang on sftp_new calling channel_open()Ashish Mangla <Ashish.Mangla@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org