Skip to content

Commit

Permalink
Change to force a rebuild of the pollset un flag changes
Browse files Browse the repository at this point in the history
This change fixes issues seen in ros#1357
Goes with ros#1281
  • Loading branch information
guillaumeautran committed May 9, 2018
1 parent e1ac4cf commit aa525d3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions clients/roscpp/src/libros/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ void close_socket_watcher(int fd) {
void add_socket_to_watcher(int epfd, int fd) {
#if defined(HAVE_EPOLL)
struct epoll_event ev;
bzero(&ev, sizeof(ev));

ev.events = 0;
ev.data.fd = fd;

Expand Down Expand Up @@ -147,6 +149,8 @@ void del_socket_from_watcher(int epfd, int fd) {
void set_events_on_socket(int epfd, int fd, int events) {
#if defined(HAVE_EPOLL)
struct epoll_event ev;
bzero(&ev, sizeof(ev));

ev.events = events;
ev.data.fd = fd;
if (::epoll_ctl(epfd, EPOLL_CTL_MOD, fd, &ev))
Expand Down
2 changes: 2 additions & 0 deletions clients/roscpp/src/libros/poll_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ bool PollSet::addEvents(int sock, int events)

set_events_on_socket(epfd_, sock, it->second.events_);

sockets_changed_ = true;
signal();

return true;
Expand All @@ -161,6 +162,7 @@ bool PollSet::delEvents(int sock, int events)

set_events_on_socket(epfd_, sock, it->second.events_);

sockets_changed_ = true;
signal();

return true;
Expand Down
2 changes: 1 addition & 1 deletion test/test_roscpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
catkin_add_gtest(${PROJECT_NAME}-test_version test_version.cpp)
if(TARGET ${PROJECT_NAME}-test_version)
target_link_libraries(${PROJECT_NAME}-test_version)
target_link_libraries(${PROJECT_NAME}-test_version ${catkin_LIBRARIES})
endif()

catkin_add_gtest(${PROJECT_NAME}-test_header test_header.cpp)
Expand Down
6 changes: 4 additions & 2 deletions test/test_roscpp/test/test_poll_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ TEST_F(Poller, write)
{
SocketHelper sh(sockets_[0]);
ASSERT_TRUE(poll_set_.addSocket(sh.socket_, boost::bind(&SocketHelper::processEvents, &sh, _1)));
ASSERT_TRUE(poll_set_.addEvents(sh.socket_, POLLOUT));

poll_set_.update(1);

ASSERT_TRUE(poll_set_.addEvents(sh.socket_, POLLOUT));
poll_set_.update(1);
ASSERT_EQ(sh.pollouts_received_, 1);
ASSERT_EQ(sh.bytes_written_, 1);

Expand All @@ -191,6 +192,8 @@ TEST_F(Poller, readAndWrite)
ASSERT_TRUE(poll_set_.addSocket(sh1.socket_, boost::bind(&SocketHelper::processEvents, &sh1, _1)));
ASSERT_TRUE(poll_set_.addSocket(sh2.socket_, boost::bind(&SocketHelper::processEvents, &sh2, _1)));

poll_set_.update(1);

ASSERT_TRUE(poll_set_.addEvents(sh1.socket_, POLLIN));
ASSERT_TRUE(poll_set_.addEvents(sh2.socket_, POLLIN));

Expand Down Expand Up @@ -402,4 +405,3 @@ int main(int argc, char** argv)

return RUN_ALL_TESTS();
}

8 changes: 4 additions & 4 deletions test/test_roscpp/test_serialization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ endif()

catkin_add_gtest(${PROJECT_NAME}-serialization src/serialization.cpp)
if(TARGET ${PROJECT_NAME}-serialization)
target_link_libraries(${PROJECT_NAME}-serialization ${catkin_LIBRARIES} ${GTEST_LIBRARIES})
target_link_libraries(${PROJECT_NAME}-serialization ${GTEST_LIBRARIES} ${catkin_LIBRARIES})
add_dependencies(${PROJECT_NAME}-serialization ${${PROJECT_NAME}_EXPORTED_TARGETS})
endif()

catkin_add_gtest(${PROJECT_NAME}-generated_messages src/generated_messages.cpp)
if(TARGET ${PROJECT_NAME}-generated_messages)
target_link_libraries(${PROJECT_NAME}-generated_messages ${catkin_LIBRARIES} ${GTEST_LIBRARIES})
target_link_libraries(${PROJECT_NAME}-generated_messages ${GTEST_LIBRARIES} ${catkin_LIBRARIES})
add_dependencies(${PROJECT_NAME}-generated_messages ${${PROJECT_NAME}_EXPORTED_TARGETS})
endif()

add_executable(${PROJECT_NAME}-builtin_types EXCLUDE_FROM_ALL src/builtin_types.cpp)
add_dependencies(tests ${PROJECT_NAME}-builtin_types)
target_link_libraries(${PROJECT_NAME}-builtin_types ${catkin_LIBRARIES} ${GTEST_LIBRARIES})
target_link_libraries(${PROJECT_NAME}-builtin_types ${GTEST_LIBRARIES} ${catkin_LIBRARIES})
add_dependencies(${PROJECT_NAME}-builtin_types ${${PROJECT_NAME}_EXPORTED_TARGETS})
add_rostest(test/builtin_types.test)

add_executable(${PROJECT_NAME}-pre_deserialize EXCLUDE_FROM_ALL src/pre_deserialize.cpp)
add_dependencies(tests ${PROJECT_NAME}-pre_deserialize)
target_link_libraries(${PROJECT_NAME}-pre_deserialize ${catkin_LIBRARIES} ${GTEST_LIBRARIES})
target_link_libraries(${PROJECT_NAME}-pre_deserialize ${GTEST_LIBRARIES} ${catkin_LIBRARIES})
add_dependencies(${PROJECT_NAME}-pre_deserialize ${${PROJECT_NAME}_EXPORTED_TARGETS})
add_rostest(test/pre_deserialize.test)

0 comments on commit aa525d3

Please sign in to comment.