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

Fwd: Re: Infinite Blocking! Need Help



-------- Message original --------
Sujet: Re: Infinite Blocking! Need Help
Date : Wed, 04 May 2011 20:06:29 +0200
De : Aris Adamantiadis <aris@xxxxxxxxxxxx>
Pour : Preston, Robert W CIV SPAWARSYSCEN-PACIFIC, 56430
<robert.w.preston@xxxxxxxx>
Copie à : support@xxxxxxxxxx

Hi Preston,

I suggest you send your email on the mailing list
(http://www.libssh.org/communication/) where more people will be able
to comment.
You're using milo's branch, are you up to date or using a specific
version? Which OS ?

If you're stuck in a select, it means that you're currently running a
blocking libssh call. A stacktrace + some code sample would be very
useful to help out.

Kr,

Aris

Le 04/05/11 18:57, Preston, Robert W CIV SPAWARSYSCEN-PACIFIC, 56430 a
écrit :
>  
> Hi all,
>  
> I could really use some help with the following issue. I'm using libssh
> to transfer files via sftp and everything is working well except for
> when I test it with my server down. I would expect the for the polling
> to timeout and return a failure so that the program log the failed
> connection. Instead the program polls for ever on the line select call
> in the following
> function:                                                
> staticintbsd_poll(ssh_pollfd_t *fds, nfds_t nfds, inttimeout) {
> 
> fd_set readfds, writefds, exceptfds;
> 
> structtimeval tv, *ptv;
> 
> socket_t max_fd;
> 
> intrc;
> 
> nfds_t i;
> 
> if(fds == NULL) {
> 
> errno = EFAULT;
> 
> return-1;
> 
> }
> 
> FD_ZERO (&readfds);
> 
> FD_ZERO (&writefds);
> 
> FD_ZERO (&exceptfds);
> 
> /* compute fd_sets and find largest descriptor */
> 
> for(rc = -1, max_fd = 0, i = 0; i < nfds; i++) {
> 
> if(fds[i].fd == SSH_INVALID_SOCKET) {
> 
> continue;
> 
> }
> 
> #ifndef_WIN32
> 
> if(fds[i].fd >= FD_SETSIZE) {
> 
> rc = -1;
> 
> break;
> 
> }
> 
> #endif
> 
> if(fds[i].events & (POLLIN | POLLRDNORM)) {
> 
> FD_SET (fds[i].fd, &readfds);
> 
> }
> 
> if(fds[i].events & (POLLOUT | POLLWRNORM | POLLWRBAND)) {
> 
> FD_SET (fds[i].fd, &writefds);
> 
> }
> 
> if(fds[i].events & (POLLPRI | POLLRDBAND)) {
> 
> FD_SET (fds[i].fd, &exceptfds);
> 
> }
> 
> if(fds[i].fd > max_fd &&
> 
> (fds[i].events & (POLLIN | POLLOUT | POLLPRI |
> 
> POLLRDNORM | POLLRDBAND |
> 
> POLLWRNORM | POLLWRBAND))) {
> 
> max_fd = fds[i].fd;
> 
> rc = 0;
> 
> }
> 
> }
> 
> if(max_fd == SSH_INVALID_SOCKET || rc == -1) {
> 
> errno = EINVAL;
> 
> return-1;
> 
> }
> 
> if(timeout < 0) {
> 
> ptv = NULL;
> 
> } else{
> 
> ptv = &tv;
> 
> if(timeout == 0) {
> 
> tv.tv_sec = 0;
> 
> tv.tv_usec = 0;
> 
> } else{
> 
> tv.tv_sec = timeout / 1000;
> 
> tv.tv_usec = (timeout % 1000) * 1000;
> 
> }
> 
> }
> 
> rc = select (max_fd + 1, &readfds, &writefds, &exceptfds, ptv);
> 
> if(rc < 0) {
> 
> return-1;
> 
> }
> 
> for(rc = 0, i = 0; i < nfds; i++)
> 
> if(fds[i].fd >= 0) {
> 
> fds[i].revents = 0;
> 
> if(FD_ISSET(fds[i].fd, &readfds)) {
> 
> intsave_errno = errno;
> 
> chardata[64] = {0};
> 
> intret;
> 
> /* support for POLLHUP */
> 
> ret = recv(fds[i].fd, data, 64, MSG_PEEK);
> 
> #ifdef_WIN32
> 
> if((ret == -1) &&
> 
> (errno == WSAESHUTDOWN || errno == WSAECONNRESET ||
> 
> errno == WSAECONNABORTED || errno == WSAENETRESET)) {
> 
> #else
> 
> if((ret == -1) &&
> 
> (errno == ESHUTDOWN || errno == ECONNRESET ||
> 
> errno == ECONNABORTED || errno == ENETRESET)) {
> 
> #endif
> 
> fds[i].revents |= POLLHUP;
> 
> } else{
> 
> fds[i].revents |= fds[i].events & (POLLIN | POLLRDNORM);
> 
> }
> 
> errno = save_errno;
> 
> }
> 
> if(FD_ISSET(fds[i].fd, &writefds)) {
> 
> fds[i].revents |= fds[i].events & (POLLOUT | POLLWRNORM | POLLWRBAND);
> 
> }
> 
> if(FD_ISSET(fds[i].fd, &exceptfds)) {
> 
> fds[i].revents |= fds[i].events & (POLLPRI | POLLRDBAND);
> 
> }
> 
> if(fds[i].revents & ~POLLHUP) {
> 
> rc++;
> 
> }
> 
> } else{
> 
> fds[i].revents = POLLNVAL;
> 
> }
> 
> returnrc;
> 
> }
> 
>  
> 
>  
> 
>  I am using a branch I found at the following location
> https://red.libssh.org/issues/42
> 
>  
> 
>  
> 
>  
> 
> Any ideas on a work around for this issue? Any help would be much
> appreciated.
> 
>  
> Robert W. Preston
> *SSC-PACIFIC 56430*
> *Office:  619-221-5222*
> *Cell:     915.929.4452*
> *robert.w.preston@xxxxxxxx* <mailto:robert.w.preston@xxxxxxxx>

Archive administrator: postmaster@lists.cynapses.org