This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

NDK is stuck after relaunching the kernel.

Hello,

I'm working with C6748, NDK 2.20.05.33, BIOS 5.41.11.38, nsp_1_00_00_09.

I have a relaunch sequence  for the NDK kernel in my application:

  1. First the stack is launched and running till some application event occurs which closes and shuts down the stack.
  2. Then another application event occurs, which relaunches the NDK kernel once again.
My shut down sequence releases/frees all previously allocated resources properly. As far as I understand, the closure and the release of the socket handle is performed by the stack via release of the file descriptor, am I right?
In the step 2. the NDK kernel is stuck in function SockPcbFind(...), after I try to connect the socket to the host via connect() API.
What can be a problem, which makes the NDK kernel stuck on this connection attempt here?
Thank you, Anatoly.
  • Hi Anatoly,

    I need to check back with our NDK expert. Either he or myself will get back to you.

  • Anatoly,

    First off, I highly recommend that you update your NDK to version 2.20.06.35 (http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/ndk/2_20_06_35/index_FDS.html), as there is a critical bug that was fixed in this version that exists in 2.20.05.33 causing the NDK heartbeat to be computed incorrectly.  This causes timing problems and affects the retransmission of TCP/IP packets.

    Anatoly Odler said:
    As far as I understand, the closure and the release of the socket handle is performed by the stack via release of the file descriptor, am I right?

    Yes, calling fdCloseSession() in turn calls SockClose() which frees socket buffers, etc.

    Anatoly Odler said:
    In the step 2. the NDK kernel is stuck in function SockPcbFind(...), after I try to connect the socket to the host via connect() API.

    Is the program actually stuck in SockPcbFind()? Or is that function returning not found?

    The SockPcbFind() function iterates over a list of all of the sockets.  Perhaps it is never reaching the end of the list for some reason?

    Steve

  • I'm working with the ndk 2.20.06.35, I have mentioned the older version by mistake.

    Steven Connell said:
    Yes, calling fdCloseSession() in turn calls SockClose() which frees socket buffers, etc.

    Do you mean I don't need to call fdClose(MySocket) to release the socket handle, but call fdCloseSession() for each task handle, that uses the same socket handle?

    Steven Connell said:
    Is the program actually stuck in SockPcbFind()?

    - Yes, it is.

    That's why I thought there's a problem with releasing the socket handle, like SockPcbFind() tries to find it, but it is overwritten somehow or the socket handle isn't released properly.

    Does fdCloseSession() actually release the socket handle or there's need to call other API to release it?

    Thank you.

  • Anatoly Odler said:
    Do you mean I don't need to call fdClose(MySocket) to release the socket handle, but call fdCloseSession() for each task handle, that uses the same socket handle?

    You should only need to call fdCloseSession().  The following skeleton code (found in "3.1.2.1 When to Initialize the File Descriptor Environment" of the NDK API Guide) outlines how a sockets task would look:

    void socket_task(int IPAddr, int TcpPort)
    {
        SOCKET s;

        // Open the file session
        fdOpenSession(TaskSelf());

        < socket application code >

        // Close the file session
        fdCloseSession(TaskSelf());
    }

    Anatoly Odler said:

    Is the program actually stuck in SockPcbFind()?

    - Yes, it is.

    That's why I thought there's a problem with releasing the socket handle, like SockPcbFind() tries to find it, but it is overwritten somehow or the socket handle isn't released properly.

    [/quote]

    Can you step through this function and see what's going on?  You will need to rebuild the stack library for debug mode (please refer to the instructions for doing this that are linked in the release notes).

    Basically you will need to make a copy of your NDK installation.  For debug mode, you need to add the "-g" compiler option into  the config.bld file.  Then rebuild but first point your project to the rebuilt version of the NDK.  Again, refer to the instructions on the wiki link.

    Steve

  • It seems like fdClose(MySocket) really solves the problem here.

    I'll try to check out what's going on in the SockPcbFind() and let you know later.

    Thank you.