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

Iox #1142 add service discovery c binding #1160

Conversation

FerdinandSpitzschnueffler
Copy link
Contributor

@FerdinandSpitzschnueffler FerdinandSpitzschnueffler commented Feb 23, 2022

Pre-Review Checklist for the PR Author

  1. Code follows the coding style of CONTRIBUTING.md
  2. Tests follow the best practice for testing
  3. Changelog updated in the unreleased section including API breaking changes
  4. Branch follows the naming format (iox-#123-this-is-a-branch)
  5. Commits messages are according to this guideline
    • Commit messages have the issue ID (iox-#123 commit text)
    • Commit messages are signed (git commit -s)
    • Commit author matches Eclipse Contributor Agreement (and ECA is signed)
  6. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  7. Relevant issues are linked
  8. Add sensible notes for the reviewer
  9. All checks have passed (except task-list-completed)
  10. Assign PR to reviewer

Notes for Reviewer

This PR introduces the service discovery C binding. The examples will follow in another PR.

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Code according to our coding style and naming conventions
  • Unit tests have been written for new behavior
    • Each unit test case has a unique UUID
  • Public API changes are documented via doxygen
  • Copyright owner are updated in the changed files
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

@FerdinandSpitzschnueffler FerdinandSpitzschnueffler force-pushed the iox-#1142-add-service-discovery-c-binding branch 5 times, most recently from 4bb66e7 to cf121cc Compare February 23, 2022 20:31
@FerdinandSpitzschnueffler FerdinandSpitzschnueffler marked this pull request as ready for review February 23, 2022 21:02
@codecov
Copy link

codecov bot commented Feb 23, 2022

Codecov Report

Merging #1160 (c9a4d43) into master (1788a02) will increase coverage by 0.34%.
The diff coverage is 96.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1160      +/-   ##
==========================================
+ Coverage   77.78%   78.12%   +0.34%     
==========================================
  Files         352      353       +1     
  Lines       14291    14408     +117     
  Branches     2014     2030      +16     
==========================================
+ Hits        11116    11256     +140     
+ Misses       2494     2460      -34     
- Partials      681      692      +11     
Flag Coverage Δ
unittests 77.33% <96.58%> (+0.34%) ⬆️
unittests_timing 14.11% <23.93%> (+0.45%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...include/iceoryx_posh/runtime/service_discovery.hpp 100.00% <ø> (+100.00%) ⬆️
iceoryx_binding_c/source/c_wait_set.cpp 88.52% <88.88%> (+0.03%) ⬆️
iceoryx_binding_c/source/c_listener.cpp 85.00% <89.47%> (+0.84%) ⬆️
...ceoryx_binding_c/source/c2cpp_enum_translation.cpp 100.00% <100.00%> (ø)
iceoryx_binding_c/source/c_notification_info.cpp 100.00% <100.00%> (ø)
iceoryx_binding_c/source/c_service_discovery.cpp 100.00% <100.00%> (ø)
iceoryx_hoofs/source/concurrent/loffli.cpp 80.00% <0.00%> (-11.43%) ⬇️
...nternal/popo/building_blocks/chunk_distributor.inl 95.93% <0.00%> (+1.62%) ⬆️
iceoryx_posh/source/runtime/service_discovery.cpp 52.83% <0.00%> (+52.83%) ⬆️

Copy link
Contributor

@MatthiasKillat MatthiasKillat left a comment

Choose a reason for hiding this comment

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

Partial review

// the value of the array size is the result of the following formula:
// sizeof(ServiceDiscovery) / 8
#if defined(__APPLE__)
uint64_t do_not_touch_me[49175];
Copy link
Contributor

Choose a reason for hiding this comment

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

Appears fairly small (if it has space for 1024 Servicedescriptions each larger than 300 bytes). I am not sure something is off here. But will likely change (to something smaller) after #1151 because than we store those in dynamic memory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got the numbers via "CI Debugging". Don't forget that you have to multiply by 8.

Copy link
Contributor

@MatthiasKillat MatthiasKillat Feb 24, 2022

Choose a reason for hiding this comment

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

Ah yes ... it is a uint64_t. Why I do not know (it is 8 byte aligned then, machine word on 64 bit architectures). But I am not sure access is always aligned for the actual type (many architectures can compensate this). Note that placement new requires an aligned pointer, which is not generally true for the ones we pass (&do_not_touch_me).

TLDR: I think this is broken for some types (those with alignment greater than 8) but have not looked at the details (this is nothing particular to this PR). It is broken on machines that cannot enforce alignment on their own and even then the space may be insufficient.

If we do not have alignment > 8 types then it is ok, if we add those types in the future it can subtly break on some architectures.

iceoryx_binding_c/source/c_listener.cpp Outdated Show resolved Hide resolved
elfenpiff
elfenpiff previously approved these changes Feb 24, 2022
@FerdinandSpitzschnueffler FerdinandSpitzschnueffler force-pushed the iox-#1142-add-service-discovery-c-binding branch from 34bd520 to e54f2fb Compare February 24, 2022 13:47
Check if Semaphore::post was successful and adapt array size of service
discovery

Signed-off-by: Marika Lehmann <[email protected]>
Add nullptr check for missed elements ptr, replace magic number in
test, add findService function without context data, correct doxygen
comments

Signed-off-by: Marika Lehmann <[email protected]>
Remove nullptr check for context data, reset callback pointer in test
setup

Signed-off-by: Marika Lehmann <[email protected]>
MatthiasKillat
MatthiasKillat previously approved these changes Feb 24, 2022
@MatthiasKillat MatthiasKillat self-requested a review February 24, 2022 14:17
@MatthiasKillat
Copy link
Contributor

There is some leak problem which the address sanitizer appears to detect.

@FerdinandSpitzschnueffler FerdinandSpitzschnueffler merged commit 7faa895 into eclipse-iceoryx:master Feb 24, 2022
@FerdinandSpitzschnueffler FerdinandSpitzschnueffler deleted the iox-#1142-add-service-discovery-c-binding branch February 24, 2022 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ServiceDiscovery C binding
3 participants