/[projects]/smsdaemon/Spooler.cpp
ViewVC logotype

Diff of /smsdaemon/Spooler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 154 by torben, Sun Dec 7 08:44:22 2008 UTC revision 155 by torben, Mon Dec 8 17:14:21 2008 UTC
# Line 116  std::string Spooler::findSpoolFilename() Line 116  std::string Spooler::findSpoolFilename()
116                          ::close(fd);                          ::close(fd);
117                          return file;                          return file;
118                  }                  }
119                    int err = errno;
120                    ::close(fd);
121    
122                  if (errno == EEXIST)                  if (err == EEXIST) {
123                          continue;                          continue;
124                    }
125    
126                  if (retrycount > 20)                  if (retrycount > 20)
127                          throw std::runtime_error("to many retry attempt at creating spool file");                          throw std::runtime_error("to many retry attempt at creating spool file");
# Line 130  std::string Spooler::findSpoolFilename() Line 133  std::string Spooler::findSpoolFilename()
133    
134  void Spooler::lock()  void Spooler::lock()
135  {  {
136          fd = open(spooldir.c_str() , O_RDONLY);          lockfd = open(spooldir.c_str() , O_RDONLY);
137    
138          if (fd == -1) {          if (lockfd == -1) {
139                  errnoException("Couldn open lockfile");                  errnoException("Couldn open lockfile");
140          }          }
141    
142          int status = flock(fd, LOCK_EX);          int status = flock(lockfd, LOCK_EX);
143    
144          if (status == -1) {          if (status == -1) {
145                  errnoException();                  errnoException();
# Line 145  void Spooler::lock() Line 148  void Spooler::lock()
148    
149  void Spooler::unlock()  void Spooler::unlock()
150  {  {
151          flock(fd, LOCK_UN);          flock(lockfd, LOCK_UN);
152            close(lockfd);
153  }  }
154    
155  string Spooler::getFilename()  string Spooler::getFilename()

Legend:
Removed from v.154  
changed lines
  Added in v.155

  ViewVC Help
Powered by ViewVC 1.1.20