Commit 7a43c723 authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

added error printing

parent 5c01cf8e
...@@ -125,6 +125,8 @@ struct remi_provider : public tl::provider<remi_provider> { ...@@ -125,6 +125,8 @@ struct remi_provider : public tl::provider<remi_provider> {
mkdirs(theDir.c_str()); mkdirs(theDir.c_str());
int fd = open(theFilename.c_str(), O_RDWR | O_CREAT | O_TRUNC, theModes[i]); int fd = open(theFilename.c_str(), O_RDWR | O_CREAT | O_TRUNC, theModes[i]);
if(fd == -1) { if(fd == -1) {
std::cerr << "remi-server.cpp: open() line "
<< __LINE__ << " failed with errno " << errno << std::endl;
for(auto ffd : openedFileDescriptors) for(auto ffd : openedFileDescriptors)
close(ffd); close(ffd);
std::get<0>(result) = REMI_ERR_IO; std::get<0>(result) = REMI_ERR_IO;
...@@ -256,6 +258,8 @@ struct remi_provider : public tl::provider<remi_provider> { ...@@ -256,6 +258,8 @@ struct remi_provider : public tl::provider<remi_provider> {
continue; continue;
} }
if(ftruncate(fd, op->m_filesizes[i]) == -1) { if(ftruncate(fd, op->m_filesizes[i]) == -1) {
std::cerr << "remi-server.cpp: ftruncate() line "
<< __LINE__ << " failed with errno " << errno << std::endl;
cleanup(true); cleanup(true);
ret = REMI_ERR_IO; ret = REMI_ERR_IO;
req.respond(ret); req.respond(ret);
...@@ -263,6 +267,8 @@ struct remi_provider : public tl::provider<remi_provider> { ...@@ -263,6 +267,8 @@ struct remi_provider : public tl::provider<remi_provider> {
} }
void *segment = mmap(0, op->m_filesizes[i], PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0); void *segment = mmap(0, op->m_filesizes[i], PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0);
if(segment == NULL) { if(segment == NULL) {
std::cerr << "remi-server.cpp: mmap() line "
<< __LINE__ << " failed with errno " << errno << std::endl;
cleanup(true); cleanup(true);
ret = REMI_ERR_IO; ret = REMI_ERR_IO;
req.respond(ret); req.respond(ret);
...@@ -288,6 +294,8 @@ struct remi_provider : public tl::provider<remi_provider> { ...@@ -288,6 +294,8 @@ struct remi_provider : public tl::provider<remi_provider> {
for(auto& seg : theData) { for(auto& seg : theData) {
if(msync(seg.first, seg.second, MS_SYNC) == -1) { if(msync(seg.first, seg.second, MS_SYNC) == -1) {
std::cerr << "remi-server.cpp: msync() line "
<< __LINE__ << " failed with errno " << errno << std::endl;
// XXX we should cleanup the files that were created // XXX we should cleanup the files that were created
cleanup(true); cleanup(true);
ret = REMI_ERR_IO; ret = REMI_ERR_IO;
...@@ -344,12 +352,16 @@ struct remi_provider : public tl::provider<remi_provider> { ...@@ -344,12 +352,16 @@ struct remi_provider : public tl::provider<remi_provider> {
// and the size of the file // and the size of the file
if(fileNumber >= op->m_fds.size()) { if(fileNumber >= op->m_fds.size()) {
ret = REMI_ERR_IO; ret = REMI_ERR_IO;
std::cerr << "remi-server.cpp: line "
<< __LINE__ << " failed (fileNumber >= op->m_fds.size())" << std::endl;
cleanup(true); cleanup(true);
req.respond(ret); req.respond(ret);
return; return;
} }
if(op->m_filesizes[fileNumber] < writeOffset + data.size()) { if(op->m_filesizes[fileNumber] < writeOffset + data.size()) {
ret = REMI_ERR_IO; ret = REMI_ERR_IO;
std::cerr << "remi-server.cpp: line "
<< __LINE__ << " failed (op->m_filesizes[fileNumber] < writeOffset + data.size())" << std::endl;
cleanup(true); cleanup(true);
req.respond(ret); req.respond(ret);
return; return;
...@@ -374,6 +386,7 @@ struct remi_provider : public tl::provider<remi_provider> { ...@@ -374,6 +386,7 @@ struct remi_provider : public tl::provider<remi_provider> {
} }
if(s != data.size()) { if(s != data.size()) {
op->m_error = REMI_ERR_IO; op->m_error = REMI_ERR_IO;
std::cerr << "remi-server.cpp: line " << __LINE__ << " failed (s != data.size())" << std::endl;
} }
} }
......
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