/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Björn Påhlsson
  • Date: 2011-10-09 12:53:54 UTC
  • Revision ID: belorn@fukt.bsnet.se-20111009125354-1qpmzu91l2ox73h3
usplash is deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
465
465
            timeout = self.timeout
466
466
        self.last_checked_ok = datetime.datetime.utcnow()
467
467
        gobject.source_remove(self.disable_initiator_tag)
 
468
        self.expires = datetime.datetime.utcnow() + timeout
468
469
        self.disable_initiator_tag = (gobject.timeout_add
469
470
                                      (_timedelta_to_milliseconds
470
471
                                       (timeout), self.disable))
471
 
        self.expires = datetime.datetime.utcnow() + timeout
472
472
    
473
473
    def need_approval(self):
474
474
        self.last_approval_request = datetime.datetime.utcnow()
1394
1394
                        return
1395
1395
                    
1396
1396
                    #wait until timeout or approved
 
1397
                    #x = float(client
 
1398
                    #          ._timedelta_to_milliseconds(delay))
1397
1399
                    time = datetime.datetime.now()
1398
1400
                    client.changedstate.acquire()
1399
1401
                    (client.changedstate.wait
1514
1516
        except:
1515
1517
            self.handle_error(request, address)
1516
1518
        self.close_request(request)
1517
 
    
 
1519
            
1518
1520
    def process_request(self, request, address):
1519
1521
        """Start a new process to process the request."""
1520
 
        proc = multiprocessing.Process(target = self.sub_process_main,
1521
 
                                       args = (request,
1522
 
                                               address))
1523
 
        proc.start()
1524
 
        return proc
 
1522
        multiprocessing.Process(target = self.sub_process_main,
 
1523
                                args = (request, address)).start()
1525
1524
 
1526
1525
 
1527
1526
class MultiprocessingMixInWithPipe(MultiprocessingMixIn, object):
1533
1532
        """
1534
1533
        parent_pipe, self.child_pipe = multiprocessing.Pipe()
1535
1534
        
1536
 
        proc = MultiprocessingMixIn.process_request(self, request,
1537
 
                                                    client_address)
 
1535
        super(MultiprocessingMixInWithPipe,
 
1536
              self).process_request(request, client_address)
1538
1537
        self.child_pipe.close()
1539
 
        self.add_pipe(parent_pipe, proc)
 
1538
        self.add_pipe(parent_pipe)
1540
1539
    
1541
 
    def add_pipe(self, parent_pipe, proc):
 
1540
    def add_pipe(self, parent_pipe):
1542
1541
        """Dummy function; override as necessary"""
1543
1542
        raise NotImplementedError
1544
1543
 
1632
1631
    def server_activate(self):
1633
1632
        if self.enabled:
1634
1633
            return socketserver.TCPServer.server_activate(self)
1635
 
    
1636
1634
    def enable(self):
1637
1635
        self.enabled = True
1638
 
    
1639
 
    def add_pipe(self, parent_pipe, proc):
 
1636
    def add_pipe(self, parent_pipe):
1640
1637
        # Call "handle_ipc" for both data and EOF events
1641
1638
        gobject.io_add_watch(parent_pipe.fileno(),
1642
1639
                             gobject.IO_IN | gobject.IO_HUP,
1643
1640
                             functools.partial(self.handle_ipc,
1644
1641
                                               parent_pipe =
1645
 
                                               parent_pipe,
1646
 
                                               proc = proc))
1647
 
    
 
1642
                                               parent_pipe))
 
1643
        
1648
1644
    def handle_ipc(self, source, condition, parent_pipe=None,
1649
 
                   proc = None, client_object=None):
 
1645
                   client_object=None):
1650
1646
        condition_names = {
1651
1647
            gobject.IO_IN: "IN",   # There is data to read.
1652
1648
            gobject.IO_OUT: "OUT", # Data can be written (without
1663
1659
                                       if cond & condition)
1664
1660
        # error or the other end of multiprocessing.Pipe has closed
1665
1661
        if condition & (gobject.IO_ERR | condition & gobject.IO_HUP):
1666
 
            proc.join()
1667
1662
            return False
1668
1663
        
1669
1664
        # Read a request from the child
1693
1688
                                 functools.partial(self.handle_ipc,
1694
1689
                                                   parent_pipe =
1695
1690
                                                   parent_pipe,
1696
 
                                                   proc = proc,
1697
1691
                                                   client_object =
1698
1692
                                                   client))
1699
1693
            parent_pipe.send(True)
2135
2129
        "Cleanup function; run on exit"
2136
2130
        service.cleanup()
2137
2131
        
2138
 
        multiprocessing.active_children()
2139
2132
        while tcp_server.clients:
2140
2133
            client = tcp_server.clients.pop()
2141
2134
            if use_dbus: