public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Application is blocked on the while loop within bsd_connect() function
@ 2008-01-02 11:02 NGUYEN Thanh SILICOMP
  2008-01-03 11:55 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: NGUYEN Thanh SILICOMP @ 2008-01-02 11:02 UTC (permalink / raw)
  To: ecos-discuss

Hi all,

Firstly, happy new year & best wished to all.

I'm working on an application connecting to FTP server using ecos 
ftpclient package.  I constate that the application waits for ever on a 
blocking semaphore of cyg_tsleep() function when there is no ftp server 
available.

In fact, for connecting to ftp server, ftpclient uses connect() that 
calls itself bas_connect() in which the while loop is used for waiting 
for the connection etablishment or an error occurring :

 while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
        error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
                       netcon, 0);

        if (error)
            break;

}

The paramter timo of tsleep set to 0 makes cyg_tsleep waiting for a 
blocking semaphore at line 325 of the file synch.c 
(net/tcpip/current/src/ecos/synch.c). And the wait time is usually long 
and triggers the watchdog process in my application.

I would like to know that there is any way to set up a timeout on socket 
before calling connect() so that the application will be able to get out 
this blocking situation ?

Any idea or sugestion will be appreciated.

Thank in advance for your helps.

Thanh NGUYEN






-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Application is blocked on the while loop within  bsd_connect() function
  2008-01-02 11:02 [ECOS] Application is blocked on the while loop within bsd_connect() function NGUYEN Thanh SILICOMP
@ 2008-01-03 11:55 ` Andrew Lunn
  2008-01-04 10:09   ` [ECOS] Application is blocked on the while loop withinbsd_connect() function NGUYEN Thanh SILICOMP
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2008-01-03 11:55 UTC (permalink / raw)
  To: NGUYEN Thanh SILICOMP; +Cc: ecos-discuss

On Wed, Jan 02, 2008 at 11:57:34AM +0100, NGUYEN Thanh SILICOMP wrote:
> Hi all,
>
> Firstly, happy new year & best wished to all.
>
> I'm working on an application connecting to FTP server using ecos ftpclient 
> package.  I constate that the application waits for ever on a blocking 
> semaphore of cyg_tsleep() function when there is no ftp server available.
>
> In fact, for connecting to ftp server, ftpclient uses connect() that calls 
> itself bas_connect() in which the while loop is used for waiting for the 
> connection etablishment or an error occurring :
>
> while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
>        error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
>                       netcon, 0);
>
>        if (error)
>            break;
>
> }
>
> The paramter timo of tsleep set to 0 makes cyg_tsleep waiting for a 
> blocking semaphore at line 325 of the file synch.c 
> (net/tcpip/current/src/ecos/synch.c). And the wait time is usually long and 
> triggers the watchdog process in my application.
>
> I would like to know that there is any way to set up a timeout on socket 
> before calling connect() so that the application will be able to get out 
> this blocking situation ?
>
> Any idea or sugestion will be appreciated.

Take a look at
http://www.developerweb.net/forum/showthread.php?p=13486.  You will
need to modify the ftpclient code to implement this scheme for
connect.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Application is blocked on the while loop  withinbsd_connect()  function
  2008-01-03 11:55 ` Andrew Lunn
@ 2008-01-04 10:09   ` NGUYEN Thanh SILICOMP
  2008-01-04 14:54     ` Gary Thomas
  0 siblings, 1 reply; 4+ messages in thread
From: NGUYEN Thanh SILICOMP @ 2008-01-04 10:09 UTC (permalink / raw)
  To: ecos-discuss

Hi,

Yes, for solving the issue, i had to make a non blocking socket for 
ftpclient. Instead of using fcntl() with F_GETFL or F_SETFL that is not 
supported at this moment in Ecos,  I used ioctl with FIONBIO. My 
application seems working good now.

Once more time, thanks for your helps.

NT

Andrew Lunn a écrit :
> On Wed, Jan 02, 2008 at 11:57:34AM +0100, NGUYEN Thanh SILICOMP wrote:
>   
>> Hi all,
>>
>> Firstly, happy new year & best wished to all.
>>
>> I'm working on an application connecting to FTP server using ecos ftpclient 
>> package.  I constate that the application waits for ever on a blocking 
>> semaphore of cyg_tsleep() function when there is no ftp server available.
>>
>> In fact, for connecting to ftp server, ftpclient uses connect() that calls 
>> itself bas_connect() in which the while loop is used for waiting for the 
>> connection etablishment or an error occurring :
>>
>> while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
>>        error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
>>                       netcon, 0);
>>
>>        if (error)
>>            break;
>>
>> }
>>
>> The paramter timo of tsleep set to 0 makes cyg_tsleep waiting for a 
>> blocking semaphore at line 325 of the file synch.c 
>> (net/tcpip/current/src/ecos/synch.c). And the wait time is usually long and 
>> triggers the watchdog process in my application.
>>
>> I would like to know that there is any way to set up a timeout on socket 
>> before calling connect() so that the application will be able to get out 
>> this blocking situation ?
>>
>> Any idea or sugestion will be appreciated.
>>     
>
> Take a look at
> http://www.developerweb.net/forum/showthread.php?p=13486.  You will
> need to modify the ftpclient code to implement this scheme for
> connect.
>
>         Andrew
>
>   

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Application is blocked on the while loop  withinbsd_connect()   function
  2008-01-04 10:09   ` [ECOS] Application is blocked on the while loop withinbsd_connect() function NGUYEN Thanh SILICOMP
@ 2008-01-04 14:54     ` Gary Thomas
  0 siblings, 0 replies; 4+ messages in thread
From: Gary Thomas @ 2008-01-04 14:54 UTC (permalink / raw)
  To: NGUYEN Thanh SILICOMP; +Cc: ecos-discuss

NGUYEN Thanh SILICOMP wrote:
> Hi,
> 
> Yes, for solving the issue, i had to make a non blocking socket for 
> ftpclient. Instead of using fcntl() with F_GETFL or F_SETFL that is not 
> supported at this moment in Ecos,  I used ioctl with FIONBIO. My 
> application seems working good now.

Perhaps you could send a patch with your changes and we could
wrap them into the public source, with some CDL, etc?

> Andrew Lunn a écrit :
>> On Wed, Jan 02, 2008 at 11:57:34AM +0100, NGUYEN Thanh SILICOMP wrote:
>>  
>>> Hi all,
>>>
>>> Firstly, happy new year & best wished to all.
>>>
>>> I'm working on an application connecting to FTP server using ecos 
>>> ftpclient package.  I constate that the application waits for ever on 
>>> a blocking semaphore of cyg_tsleep() function when there is no ftp 
>>> server available.
>>>
>>> In fact, for connecting to ftp server, ftpclient uses connect() that 
>>> calls itself bas_connect() in which the while loop is used for 
>>> waiting for the connection etablishment or an error occurring :
>>>
>>> while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
>>>        error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
>>>                       netcon, 0);
>>>
>>>        if (error)
>>>            break;
>>>
>>> }
>>>
>>> The paramter timo of tsleep set to 0 makes cyg_tsleep waiting for a 
>>> blocking semaphore at line 325 of the file synch.c 
>>> (net/tcpip/current/src/ecos/synch.c). And the wait time is usually 
>>> long and triggers the watchdog process in my application.
>>>
>>> I would like to know that there is any way to set up a timeout on 
>>> socket before calling connect() so that the application will be able 
>>> to get out this blocking situation ?
>>>
>>> Any idea or sugestion will be appreciated.
>>>     
>>
>> Take a look at
>> http://www.developerweb.net/forum/showthread.php?p=13486.  You will
>> need to modify the ftpclient code to implement this scheme for
>> connect.
>>
>>         Andrew
>>
>>   
> 


-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-04 14:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-02 11:02 [ECOS] Application is blocked on the while loop within bsd_connect() function NGUYEN Thanh SILICOMP
2008-01-03 11:55 ` Andrew Lunn
2008-01-04 10:09   ` [ECOS] Application is blocked on the while loop withinbsd_connect() function NGUYEN Thanh SILICOMP
2008-01-04 14:54     ` Gary Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).