Skip to content
Snippets Groups Projects
Commit 05fd4aa7 authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #2669: Sync NFS before unlinking the nfsKey as well.

parent 914dbcca
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,8 @@ class SocketStream : public FileDescriptorBasedStream ...@@ -64,6 +64,8 @@ class SocketStream : public FileDescriptorBasedStream
void accept(time_t timeout); void accept(time_t timeout);
static void syncNFS();
static std::string readkey(const string &nfskey, time_t &timeout); static std::string readkey(const string &nfskey, time_t &timeout);
static void writekey(const string &nfskey, uint16 port); static void writekey(const string &nfskey, uint16 port);
static void deletekey(const string &nfskey); static void deletekey(const string &nfskey);
......
...@@ -261,24 +261,30 @@ void SocketStream::setReadBufferSize(size_t size) ...@@ -261,24 +261,30 @@ void SocketStream::setReadBufferSize(size_t size)
} }
std::string SocketStream::readkey(const std::string &nfskey, time_t &timeout) void SocketStream::syncNFS()
{ {
for(;;) { // sync NFS
// sync NFS DIR *dir = opendir(".");
DIR *dir = opendir(".");
if (!dir) if (!dir)
throw SystemCallException("opendir", errno, THROW_ARGS); throw SystemCallException("opendir", errno, THROW_ARGS);
if (!readdir(dir)) if (!readdir(dir))
throw SystemCallException("readdir", errno, THROW_ARGS); throw SystemCallException("readdir", errno, THROW_ARGS);
if (closedir(dir) != 0) if (closedir(dir) != 0)
throw SystemCallException("closedir", errno, THROW_ARGS); throw SystemCallException("closedir", errno, THROW_ARGS);
}
std::string SocketStream::readkey(const std::string &nfskey, time_t &timeout)
{
for(;;) {
char portStr[16]; char portStr[16];
ssize_t len; ssize_t len;
syncNFS();
len = readlink(nfskey.c_str(), portStr, sizeof portStr - 1); // reserve 1 character to insert \0 below len = readlink(nfskey.c_str(), portStr, sizeof portStr - 1); // reserve 1 character to insert \0 below
if (len >= 0) { if (len >= 0) {
...@@ -313,6 +319,8 @@ void SocketStream::writekey(const std::string &nfskey, uint16 port) ...@@ -313,6 +319,8 @@ void SocketStream::writekey(const std::string &nfskey, uint16 port)
void SocketStream::deletekey(const std::string &nfskey) void SocketStream::deletekey(const std::string &nfskey)
{ {
syncNFS();
if (unlink(nfskey.c_str()) < 0) if (unlink(nfskey.c_str()) < 0)
throw SystemCallException("unlink", errno, THROW_ARGS); throw SystemCallException("unlink", errno, THROW_ARGS);
} }
......
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