Revision 25d6d12a

b/daemons/ganeti-noded
39 39
from ganeti import constants
40 40
from ganeti import objects
41 41
from ganeti import errors
42
from ganeti import jstore
42 43
from ganeti import ssconf
43 44
from ganeti import http
44 45
from ganeti import utils
45 46

  
46 47

  
48
queue_lock = None
49

  
50

  
47 51
class NodeDaemonRequestHandler(http.HTTPRequestHandler):
48 52
  """The server implementation.
49 53

  
......
539 543

  
540 544
    """
541 545
    (file_name, content) = params
542
    return backend.JobQueueUpdate(file_name, content)
546

  
547
    # Locking in exclusive, blocking mode because there could be several
548
    # children running at the same time.
549
    # TODO: Implement nonblocking locking with retries?
550
    queue_lock.Exclusive(blocking=True)
551
    try:
552
      return backend.JobQueueUpdate(file_name, content)
553
    finally:
554
      queue_lock.Unlock()
543 555

  
544 556
  @staticmethod
545 557
  def perspective_jobqueue_purge(params):
......
600 612
  """Main function for the node daemon.
601 613

  
602 614
  """
615
  global queue_lock
616

  
603 617
  options, args = ParseOptions()
604 618
  utils.debug = options.debug
605 619
  for fname in (constants.SSL_CERT_FILE,):
......
640 654
                      stderr_logging=not options.fork)
641 655
  logging.info("ganeti node daemon startup")
642 656

  
657
  # Prepare job queue
658
  queue_lock = jstore.InitAndVerifyQueue(must_lock=False)
659

  
643 660
  if options.fork:
644 661
    server = ForkingHTTPServer(('', port))
645 662
  else:

Also available in: Unified diff