Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Open Port Request on Sending Side of IpSocket #2683

Merged
merged 11 commits into from
Sep 25, 2024

Conversation

csmith608
Copy link
Collaborator

@csmith608 csmith608 commented Apr 16, 2024

Related Issue(s) #2553
Has Unit Tests (y/n) y
Documentation Included (y/n) y

Change Description

Update IpSocket to check socket state on sending side and open socket if necessary

Rationale

This fixes a bug encountered while using IpSocket. The server would close the TCP connection and then the client would try to send and fail because previously IpSocket would only re-open a TCP connection when it received over the socket.

Testing/Review Recommendations

In my project's version of fprime we diverged at fprime 3.0. I added implementations for the close() port in the TcpClient, TcpServer, and Udp as well as unit tests. This change also fixed the issue we were seeing with sending data, but the socket not being there.
This does not include the unit tests or implementations for close() in the ByteStreamDriverModel because I wanted to at least get this part of the change in. I'll work on adding them.
I also ended up commenting out line 85 of Drv/Ip/SocketReadTask.cpp because when I was running other testing without the TCP server, I was being spammed with that logger message.

Future Work

Adding implementations for close() to TcpClient, TcpServer, and Udp as well as unit tests.

(Pipeline failed on "spammed" but I stand behind my spelling, but perhaps not that comment)

Drv/Ip/SocketReadTask.cpp Fixed Show fixed Hide fixed
Drv/Ip/IpSocket.cpp Fixed Show fixed Hide fixed
Drv/Ip/SocketReadTask.cpp Fixed Show fixed Hide fixed
@LeStarch
Copy link
Collaborator

Looks like it passed CI. We'll need to correct spelling. Your spelling is right, so we need to add the word to the expect list.

@LeStarch
Copy link
Collaborator

The list is at: .github/actions/spelling/expect.txt. Just place "spammed" in there is mostly alphabetical order. I can help this afternoon, but the above shows you how to should you get to it sooner.

@LeStarch
Copy link
Collaborator

Fixed the spelling issue. Will review now.

@LeStarch LeStarch self-requested a review April 16, 2024 23:14
Copy link
Collaborator

@LeStarch LeStarch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I feel dumb, these comments were left as pending for several weeks.

Drv/Ip/SocketReadTask.cpp Outdated Show resolved Hide resolved
Drv/Ip/SocketReadTask.cpp Fixed Show fixed Hide fixed
@csmith608
Copy link
Collaborator Author

@LeStarch I added a unit test to TcpClient and TcpServer to show the socket auto opening, so I think this should be okay to merge (if it passes the checks).

Drv/Ip/SocketReadTask.cpp Fixed Show fixed Hide fixed
@thomas-bc thomas-bc requested a review from LeStarch July 17, 2024 22:56
@csmith608
Copy link
Collaborator Author

Better way of doing this:

  • Have an active component with one thread that processes events
  • Events are send events that come from outside
  • Another thread is blocking on input that sends the receive events
  • If a send event is processed and the socket isn't open, it opens
  • If on a receive the socket isn't open it opens
  • All mediated by a queue
  • One thread is from the active TCP*Impl.cpp and the receive thread

crsmith added 2 commits August 30, 2024 13:04
…oved behavior to the component level by placing thread protection behavior to SocketReadTask, now called SocketComponentHelper. Calls to socket functionality from TcpClient/TcpServer/Udp will go through SocketComponentHelper rather than directly to the library. This also implemented the original desired functionality of reopening a client socket on a send call rather than only in receive
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

crsmith added 3 commits September 4, 2024 15:31
…tests whos name includes more than the module name
…buffer equality check would fail because the size of the original buffer (owned by the unit test) gets set to 0, sometimes. Maybe 1/10 runs. I changed it to save the size of that buffer before it does the send and use that saved value in the equality check
Drv/Ip/SocketComponentHelper.cpp Fixed Show fixed Hide fixed
Drv/Ip/SocketComponentHelper.cpp Fixed Show fixed Hide fixed
Drv/Ip/IpSocket.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/IpSocket.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/Ip/SocketComponentHelper.cpp Dismissed Show dismissed Hide dismissed
Drv/TcpClient/TcpClientComponentImpl.cpp Dismissed Show dismissed Hide dismissed
Drv/TcpServer/TcpServerComponentImpl.cpp Dismissed Show dismissed Hide dismissed
Drv/Udp/UdpComponentImpl.cpp Dismissed Show dismissed Hide dismissed
@csmith608
Copy link
Collaborator Author

@LeStarch other than the RPi known issue, I think this PR is ready for review

Copy link
Collaborator

@LeStarch LeStarch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have lots of questions, but my guess is this is ready to merge once the dead code and TODOs are deleted!

Fantastic work!

Drv/Ip/IpSocket.cpp Outdated Show resolved Hide resolved
Drv/Ip/IpSocket.hpp Show resolved Hide resolved
Drv/Ip/SocketComponentHelper.cpp Outdated Show resolved Hide resolved
Drv/Ip/SocketComponentHelper.cpp Outdated Show resolved Hide resolved
Drv/Ip/SocketComponentHelper.cpp Show resolved Hide resolved
Drv/TcpClient/test/ut/TcpClientTester.cpp Outdated Show resolved Hide resolved
Drv/TcpServer/TcpServerComponentImpl.cpp Show resolved Hide resolved
Drv/TcpServer/test/ut/TcpServerTester.cpp Outdated Show resolved Hide resolved
Drv/TcpServer/test/ut/TcpServerTester.cpp Outdated Show resolved Hide resolved
Drv/TcpServer/test/ut/TcpServerTester.cpp Outdated Show resolved Hide resolved
@LeStarch LeStarch merged commit e0c5a89 into nasa:devel Sep 25, 2024
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants