From e7f825e55725ae4b7a3b01182a4f3b5e207ea49a Mon Sep 17 00:00:00 2001 From: Guillaume Autran Date: Thu, 10 May 2018 16:13:36 -0400 Subject: [PATCH] Change to force a rebuild of the pollset on flag changes (#1393) * Change to force a rebuild of the pollset on flag changes This change fixes issues seen in #1357, resulting from #1281 --- clients/roscpp/src/libros/io.cpp | 4 ++++ clients/roscpp/src/libros/poll_set.cpp | 2 ++ test/test_roscpp/test/CMakeLists.txt | 2 +- test/test_roscpp/test_serialization/CMakeLists.txt | 8 ++++---- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/clients/roscpp/src/libros/io.cpp b/clients/roscpp/src/libros/io.cpp index 66c4a9993a..d508cca817 100644 --- a/clients/roscpp/src/libros/io.cpp +++ b/clients/roscpp/src/libros/io.cpp @@ -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; @@ -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)) diff --git a/clients/roscpp/src/libros/poll_set.cpp b/clients/roscpp/src/libros/poll_set.cpp index 7ae227d48d..50580ee806 100644 --- a/clients/roscpp/src/libros/poll_set.cpp +++ b/clients/roscpp/src/libros/poll_set.cpp @@ -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; @@ -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; diff --git a/test/test_roscpp/test/CMakeLists.txt b/test/test_roscpp/test/CMakeLists.txt index 7328a59828..05dae977d3 100644 --- a/test/test_roscpp/test/CMakeLists.txt +++ b/test/test_roscpp/test/CMakeLists.txt @@ -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) diff --git a/test/test_roscpp/test_serialization/CMakeLists.txt b/test/test_roscpp/test_serialization/CMakeLists.txt index 27e35175d2..be7c426f60 100644 --- a/test/test_roscpp/test_serialization/CMakeLists.txt +++ b/test/test_roscpp/test_serialization/CMakeLists.txt @@ -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)