Skip to content
Snippets Groups Projects
Commit 95491704 authored by Carsten Patzke's avatar Carsten Patzke
Browse files

Fixed IO Read bug

parent 10a6fcc6
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,6 @@
#include <string>
#include <vector>
#include <chrono>
#include <sys/socket.h>
#include <memory>
#include <thread>
......
......@@ -435,7 +435,7 @@ size_t hidra2::SystemIO::Read(FileDescriptor fd, void* buf, size_t length, IOErr
size_t already_read = 0;
while(already_read < length) {
ssize_t received_amount = ::recv(fd, (uint8_t*)buf + already_read, length - already_read, 0);
ssize_t received_amount = ::read(fd, (uint8_t*)buf + already_read, length - already_read);
if(received_amount == 0) {
*err = IOErrors::kEndOfFile;
return already_read;
......@@ -488,6 +488,7 @@ void hidra2::SystemIO::CreateDirectory(const std::string& directory_name, hidra2
}
hidra2::FileData hidra2::SystemIO::GetDataFromFile(const std::string& fname, uint64_t fsize, IOErrors* err) const {
*err = IOErrors::kNoError;
FileDescriptor fd = Open(fname, IO_OPEN_MODE_READ, err);
if (*err != IOErrors::kNoError) {
return nullptr;
......@@ -499,9 +500,8 @@ hidra2::FileData hidra2::SystemIO::GetDataFromFile(const std::string& fname, uin
*err = IOErrors::kMemoryAllocationError;
return nullptr;
}
Read(fd, data_array, fsize, err);
FileData data{data_array};
Read(fd, data_array, fsize, err);
if (*err != IOErrors::kNoError) {
Close(fd, nullptr);
return nullptr;
......
......@@ -6,7 +6,7 @@ set(SOURCE_FILES read_file_content.cpp)
# Executable and link
################################
add_executable(${TARGET_NAME} ${SOURCE_FILES} $<TARGET_OBJECTS:common> )
target_link_libraries(${TARGET_NAME} test_common)
target_link_libraries(${TARGET_NAME} test_common Threads::Threads)
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/common/cpp/include)
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
......
......@@ -6,7 +6,7 @@ set(SOURCE_FILES read_folder_content.cpp)
# Executable and link
################################
add_executable(${TARGET_NAME} ${SOURCE_FILES} $<TARGET_OBJECTS:common>)
target_link_libraries(${TARGET_NAME} test_common)
target_link_libraries(${TARGET_NAME} test_common Threads::Threads)
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/common/cpp/include)
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
......
......@@ -6,7 +6,7 @@ set(SOURCE_FILES next_multithread.cpp)
# Executable and link
################################
add_executable(${TARGET_NAME} ${SOURCE_FILES})
target_link_libraries(${TARGET_NAME} test_common hidra2-worker ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET_NAME} test_common hidra2-worker Threads::Threads)
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
if (CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS_DEBUG "--coverage")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment