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

Refactoring

parent 6dad2723
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ class SystemIO final : public IO {
int SocketTypeToPosixType (SocketTypes socket_type) const;
int SocketProtocolToPosixProtocol (SocketProtocols socket_protocol) const;
// Function maps. Should never be called apart from in wrapper function
// System function mapping. Should only be called by the wrapper function
FileDescriptor _open(const char* filename, int posix_open_flags) const;
bool _close(FileDescriptor fd) const;
ssize_t _read(FileDescriptor fd, void* buffer, size_t length) const;
......
......@@ -19,7 +19,7 @@ int main (int argc, char* argv[]) {
getchar();
std::cout << "Stop listener..." << std::endl;
receiver->StopListener(&err);
receiver->StopListener(&err);//TODO might not work since Accept is a blocking call :/
return 0;
}
#include "network_producer_peer.h"
#include "receiver.h"
#include <fcntl.h>
#include <cmath>
namespace hidra2 {
......@@ -39,7 +38,7 @@ void NetworkProducerPeer::handle_send_data_request_(NetworkProducerPeer* self, c
std::cerr << "[" << self->connection_id() << "] file_id: " << request->file_id << " does already exists" << std::endl;
self->io->Skip(self->socket_fd_, request->file_size, &io_err);
if(io_err != IOErrors::kNoError) {
std::cout << "[NetworkProducerPeer] Out of sync force disconnect" << std::endl;
std::cout << "[" << self->connection_id() << "] Out of sync force disconnect" << std::endl;
self->io->CloseSocket(self->socket_fd_, nullptr);
}
return;
......@@ -60,9 +59,15 @@ void NetworkProducerPeer::handle_send_data_request_(NetworkProducerPeer* self, c
if(io_err != IOErrors::kNoError) {
std::cerr << "[" << self->connection_id() << "] An IO error occurred while receiving the file" << std::endl;
response->error_code = NET_ERR__INTERNAL_SERVER_ERROR;
return;
}
self->io->Write(fd, buffer.get(), request->file_size, &io_err);
if(io_err != IOErrors::kNoError) {
std::cerr << "[" << self->connection_id() << "] An IO error occurred while writing the file" << std::endl;
response->error_code = NET_ERR__INTERNAL_SERVER_ERROR;
return;
}
response->error_code = NET_ERR__NO_ERROR;
}
......
......@@ -17,6 +17,7 @@ TEST(a, b) {
hidra2::MockIO mockIO;
hidra2::Receiver receiver;
}
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment