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

Re: [Ftpapi] FTP API not closing socket after sending data?



I see that too now, Scott.  Hmm.. I'll do some more digging and let you know what I find.

I really only dug into this because the ftp_conn() starting failing with a -1 while testing.  (No description of the error either, but I'm sure there's something in there that lets be get the errno and description I would think).

Anyhow, I'll update with more info when I find it.  Thanks, Scott.

Bradley V. Stone
Native IBM i e-Mail solutions for Microsoft Office 365, Gmail, or any Cloud Provider! 

On Thu, Apr 20, 2017 at 3:16 PM, Scott Klement <sk@xxxxxxxxxxxxxxxx> wrote:
Brad,

The socket should actually be closed in the put_block() routine.  I can see the code that does callp close() at the end of this routine (just before it returns at the very end).  It should always close this socket -- I can't see any way that it'd get out of the put_block() routine without closing it.

This does not mean that the socket would disappear from netstat immediately.   When FTPAPI writes the last data to the socket, it immediately closes it and returns control to your program.  In the background, the OS may still be sending the data over the network. At this point, the status should change from "Established" to either "Fin-Wait-X" or "Close-Wait".   So this might be what you're seeing -- the data connection appears to be still open, but it's actually closed, but the OS still has more work to do in the background. Could that be what you're seeing?

If it still says "Established", however, then there is likely a bug somewhere.  In that case, I'll need to know exactly how to reproduce it.

-SK

On 4/20/2017 2:29 PM, Bradley Stone wrote:
Scott,

I only traced ftp_putraw() in debug from the ftp_put() that I am using.  This in a sense all my application does:

sess = ftp_conn(ip:user:pw);
ftp_binaryMode(sess: *on);
ftp_put(sess:remoteFile:localFilel);
ftp_quit(sess);

On connect I see one ftp job in netstat open.

On ftp_put() I see a second socket opened for data.

On ftp_quit() I see the first socket close, but the one created from ftp_put() stays open and eventually does time out and end after a minute or 2 (I didn't time it exactly).

I hope this helps!  I mean, I know I can go in and updated it, but I wanted to make sure I'm not doing something wrong on my end.



Bradley V. Stone
www.bvstools.com <http://www.bvstools.com>
Native IBM i e-Mail solutions for Microsoft Office 365, Gmail, or any Cloud Provider!

On Thu, Apr 20, 2017 at 2:19 PM, Scott Klement <sk@xxxxxxxxxxxxxxxx <mailto:sk@xxxxxxxxxxxxxxxx>> wrote:

    Brad,

    Does this happen with calls to ftp_put()?  Or Just ftp_putraw()?

    It's been a long time since I've looked at FTPAPI (I don't need it
    for work these days) so the more specific info you can provide,
    the better.

    Thanks!




    On 4/19/2017 11:37 AM, Bradley Stone wrote:

        FTP API beta version 3.0

        I started using FTP API for a client and so far it works great
        except for one thing... after a STOR it seems to leave the
        data socket open.

        Because we're sending a lot of files this eventually ends up
        with the system not being able to create more sockets (too
        many open) and the following FTP commands aren't run until the
        sockets eventually timeout.

        In debugging I see that the call to FTP_putraw() opens wwSock
        but it's only closed if there is an error.

        I could be missing something here. :)

        Bradley V. Stone
        www.bvstools.com <http://www.bvstools.com>
        <http://www.bvstools.com>
        Native IBM i e-Mail solutions for Microsoft Office 365, Gmail,
        or any Cloud Provider!



    --     _______________________________________________
    Ftpapi mailing list
    Ftpapi@xxxxxxxxxxxxxxxxxxxxxx <mailto:Ftpapi@lists.scottklement.com>
    http://scottklement.com/mailman/listinfo/ftpapi
    <http://scottklement.com/mailman/listinfo/ftpapi>





--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi

-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi