Skip to content

Commit

Permalink
new busy connection support
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Sep 9, 2015
1 parent 9f150f9 commit bd99292
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/netius/extra/proxy_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ def on_headers(self, connection, parser):
# sets the current connection as busy, as it's waiting for a message
# to be returned from the the back-end side, then increments the number
# of currently busy connections (as expected)
_connection.busy = True
_connection.busy = _connection.busy if hasattr(_connection, "busy") else 0
_connection.busy += 1
self.busy_conn += 1

# prints a debug message about the connection becoming a waiting
Expand Down Expand Up @@ -340,7 +341,6 @@ def acquirer_smart(self, state):
queue[prefix] = sorter

def releaser(self, state):
self.busy_conn -= 1
self.releaser_m(state)

def releaser_robin(self, state):
Expand All @@ -356,16 +356,16 @@ def releaser_smart(self, state):

def _on_prx_message(self, client, parser, message):
_connection = parser.owner
busy = _connection.busy if hasattr(_connection, "busy") else False
busy = _connection.busy if hasattr(_connection, "busy") else 0
state = _connection.state if hasattr(_connection, "state") else None
if busy: self.busy_conn -= 1; _connection.busy = False
if busy: self.busy_conn -= 1; _connection.busy -= 1
if state: self.releaser(state); _connection.state = None
netius.servers.ProxyServer._on_prx_message(self, client, parser, message)

def _on_prx_close(self, client, _connection):
busy = _connection.busy if hasattr(_connection, "busy") else False
busy = _connection.busy if hasattr(_connection, "busy") else 0
state = _connection.state if hasattr(_connection, "state") else None
if busy: self.busy_conn -= 1; _connection.busy = False
if busy: self.busy_conn -= busy; _connection.busy -= busy
if state: self.releaser(state); _connection.state = None
netius.servers.ProxyServer._on_prx_close(self, client, _connection)

Expand Down

0 comments on commit bd99292

Please sign in to comment.