示例#1
0
 def purge_connections(self):
     if len(self.clientless_connections) > 0:
         debug("Scanning for idle connections. %d connection(s) has "
               "not completed the protocol hand shake." %
               len(self.clientless_connections), LogCategory.PROTOCOL)
         now = time.time()
         failed = []
         for conn in self.clientless_connections:
             if conn.client_id is None or \
                not self.sd.has_client(conn.client_id):
                 handshake_time = now - conn.connect_time
                 if handshake_time > MAX_HANDSHAKE_TIME:
                     failed.append((conn, handshake_time))
         for conn, handshake_time in failed:
             self.purge_connection(conn, handshake_time)
示例#2
0
 def sock_activate(self):
     for source, sock in self.server_socks.items():
         if self.max_clients_reached():
             sock.finish()
             source.update(0)
         else:
             batch_size = self.client_capacity_left()
             if batch_size is None or batch_size > MAX_ACCEPT_BATCH:
                 batch_size = MAX_ACCEPT_BATCH
             for i in range(batch_size):
                 try:
                     conn_sock = sock.accept()
                     self.update_source(source)
                     conn = Connection(self.sd, conn_sock, self.event_loop,
                                       self, self.conn_handshake_completed,
                                       self.conn_terminated)
                     self.clientless_connections.add(conn)
                     self.schedule_purge()
                 except xcm.error as e:
                     self.update_source(source)
                     if e.errno != errno.EAGAIN:
                         debug("Error accepting client: %s" % e,
                               LogCategory.PROTOCOL)
                     break
示例#3
0
 def orphan_timer_activate(self):
     timed_out = self.sd.purge_orphans()
     for orphan_id in timed_out:
         debug("Timed out orphan service %x." % orphan_id, LogCategory.CORE)
     self.orphan_timer.set_timeout(self.sd.next_orphan_timeout())
示例#4
0
 def purge_connection(self, conn, handshake_time):
     debug(
         "Dropping connection from %s since it failed to "
         "finish the protocol handshake within %.1f s." %
         (conn.conn_addr, MAX_HANDSHAKE_TIME), LogCategory.PROTOCOL)
     conn.terminate()