--- smsdaemon/Spooler.cpp 2008/12/07 08:44:22 134 +++ smsdaemon/Spooler.cpp 2008/12/08 17:14:21 155 @@ -116,9 +116,12 @@ ::close(fd); return file; } + int err = errno; + ::close(fd); - if (errno == EEXIST) + if (err == EEXIST) { continue; + } if (retrycount > 20) throw std::runtime_error("to many retry attempt at creating spool file"); @@ -130,13 +133,13 @@ void Spooler::lock() { - fd = open(spooldir.c_str() , O_RDONLY); + lockfd = open(spooldir.c_str() , O_RDONLY); - if (fd == -1) { + if (lockfd == -1) { errnoException("Couldn open lockfile"); } - int status = flock(fd, LOCK_EX); + int status = flock(lockfd, LOCK_EX); if (status == -1) { errnoException(); @@ -145,7 +148,8 @@ void Spooler::unlock() { - flock(fd, LOCK_UN); + flock(lockfd, LOCK_UN); + close(lockfd); } string Spooler::getFilename()