Commit 0dea3f96 authored by Stanislav Bohm's avatar Stanislav Bohm

FIX: Disposing raw data fixed

parent a3a1fc21
......@@ -23,12 +23,12 @@ RawData::RawData()
RawData::~RawData()
{
llog->debug("Disposing raw data filename={}", filename);
llog->debug("Disposing raw data filename={} size={}", filename, size);
if (filename.empty()) {
assert(data == nullptr);
} else {
if (munmap(data, size)) {
if (size > 0 && munmap(data, size)) {
log_errno_abort("munmap");
}
if (unlink(filename.c_str())) {
......@@ -42,15 +42,6 @@ std::string RawData::get_type_name() const
return RawDataUnpacker::get_type_name();
}
/*char* RawData::init_memonly(size_t size)
{
assert(data == nullptr);
assert(file_id == 0);
this->size = size;
data = new char[size];
return data;
}*/
char* RawData::init_empty(Worker &worker, size_t size)
{
assert(data == nullptr);
......@@ -125,6 +116,10 @@ void RawData::map(int fd, bool write)
assert(!filename.empty());
assert(fd >= 0);
if (size == 0) {
return;
}
int flags = PROT_READ;
if (write) {
flags |= PROT_WRITE;
......
......@@ -21,7 +21,7 @@ InterConnection::~InterConnection()
void InterConnection::on_connection()
{
llog->debug("Connected");
llog->info("Connected to {}", get_address());
connection.start_read();
loomcomm::Announce msg;
msg.set_port(worker.get_listen_port());
......
......@@ -72,5 +72,11 @@ int loom::make_path(const char *path, mode_t mode)
void loom::log_errno_abort(const char *tmp)
{
llog->critical("{}: {}", tmp, strerror(errno));
exit(1);
abort();
}
void loom::log_errno_abort(const char *tmp, const char *tmp2)
{
llog->critical("{}: {} ({})", tmp, strerror(errno), tmp2);
abort();
}
......@@ -17,6 +17,8 @@ namespace loom {
void report_uv_error(int error_code, int line_number, const char *filename) __attribute__ ((noreturn));
void log_errno_abort(const char *tmp) __attribute__ ((noreturn));
void log_errno_abort(const char *tmp, const char *tmp2) __attribute__ ((noreturn));
int make_path(const char *path, mode_t mode);
size_t file_size(const char *path);
......
......@@ -476,7 +476,7 @@ void ServerConnection::on_message(const char *data, size_t size)
if (address.size() > 2 && address[0] == '!' && address[1] == ':') {
msg.set_address(worker.get_server_address() + ":" + address.substr(2, std::string::npos));
}
llog->debug("Sending data {} to {}", msg.id(), msg.address());
llog->debug("Sending data id={} to {}", msg.id(), msg.address());
bool with_size = msg.has_with_size() && msg.with_size();
assert(worker.send_data(msg.address(), msg.id(), with_size));
break;
......
......@@ -58,8 +58,9 @@ class LoomEnv(Env):
server_args = (LOOM_SERVER_BIN,
"--debug",
"--port=" + str(self.PORT))
valgrind_args = ("valgrind", "--num-callers=40")
if VALGRIND:
server_args = ("valgrind",) + server_args
server_args = valgrind_args + server_args
server = self.start_process("server", server_args)
time.sleep(0.1)
assert not server.poll()
......@@ -71,7 +72,7 @@ class LoomEnv(Env):
"localhost", str(self.PORT))
if VALGRIND:
time.sleep(2)
worker_args = ("valgrind",) + worker_args
worker_args = valgrind_args + worker_args
for i in xrange(workers_count):
w = self.start_process("worker{}".format(i), worker_args)
workers.append(w)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment