Commit Graph

78 Commits

Author SHA1 Message Date
Trygve Aaberge
265951bf00 network: disable_recv before telling actor to close connection
As of d62ad96, when the connection can't receive more data from the
client, it tells the actor to stop the connection and calls
disable_recv(). The actor operates in it's own thread and when it stops
the connection, disable_recv is being called again from a different
thread. Since the actor is told to stop the connection before
disable_recv is called, the two calls to disable_recv may happen
simultaneously.

This causes a race condition issue where both threads can reach past the
check that recv_id is not None before either of them set it to None. If
one of them set it to None before the other one tries to use it, an
error is raised.

This commit calls disable_recv before telling the actor to stop the
connection. Since disable_recv is a blocking call, this ensures that
recv_id is being set to None before the actor thread begins to stop the
connection.

Fixes #781
2014-08-14 01:58:48 +02:00
Stein Magnus Jodal
b754885064 Fix all import order warnings 2014-05-07 20:08:43 +02:00
Trygve Aaberge
d62ad966af network: Respond to messages before closing connections
This makes a connection tell the actor to stop the connection, instead
of stopping it itself. This is preferable, because other messages sent
to the actor that is not processed yet, may now send data to the client.

E.g. it makes this work:
$ echo status | nc localhost 6600
2014-04-25 06:11:01 +02:00
Thomas Adamcik
4453df7594 network: Check for windows platform match 2014-01-24 19:18:30 +01:00
Arnaud Barisain-Monrose
fe3c27cf18 Add windows workaround for IPv6 sockets to also listen on IPv4 2014-01-19 23:05:00 +01:00
Stein Magnus Jodal
0fb7c79524 log: Use loggers named after __name__ 2014-01-01 13:31:20 +01:00
Stein Magnus Jodal
79cbdb4fbb mpd: Add MPD_SERVER_CONNECTION_TIMEOUT setting 2012-12-19 23:47:22 +01:00
Stein Magnus Jodal
6aa1ee7f5c network: The recieve buffer should be a bytestring 2012-11-19 22:18:51 +01:00
Stein Magnus Jodal
8a440fff3f network: Server send buffer should be bytes, not unicode (#241) 2012-11-14 18:12:52 +01:00
Stein Magnus Jodal
6acaa490e9 Make all strings unicode by default (fixes #224) 2012-11-13 00:18:47 +01:00
Stein Magnus Jodal
d685fe554c Simplify pykka imports 2012-10-26 22:57:41 +02:00
Stein Magnus Jodal
587dde287f Update to work with Pykka 1.0 2012-10-26 22:32:06 +02:00
Stein Magnus Jodal
8042f9961a Mark strings with backslashes as raw strings (#211) 2012-10-17 01:07:00 +02:00
Stein Magnus Jodal
5a0529b142 Empty utils/__init__.py 2012-10-16 21:36:51 +02:00
Stein Magnus Jodal
666800ec57 Fix most flake8 warnings (#211) 2012-10-16 14:00:34 +02:00
Stein Magnus Jodal
63cd153b1b Let NetworkServer pass protocol_kwargs on 2012-09-28 00:48:23 +02:00
Stein Magnus Jodal
66f476e85a Fix typo 2012-09-26 10:08:59 +02:00
Thomas Adamcik
ab7d0c4cc2 Don't block gobject event thread, fixes #150. 2012-09-09 21:36:52 +02:00
Stein Magnus Jodal
d6f17b4cf0 Decode messages from IOError before logging them
IOError messages are bytestrings, often in the language of the system, so they
may include non-ASCII characters. Thus, we must decode them using the locale's
preferred encoding to get Unicode objects we safely can pass on for logging
the IOError.
2012-08-10 23:17:41 +02:00
Stein Magnus Jodal
2eae7aaae1 Call ThreadingActor/etc constructors to please pylint 2012-02-10 00:30:18 +01:00
Thomas Adamcik
34594e40e8 Move method and cleanup docstrings 2011-07-28 22:55:54 +02:00
Thomas Adamcik
cb4f32cb58 Try to send directly in quene_send when we can to prevent uneeded context switches 2011-07-28 22:51:41 +02:00
Thomas Adamcik
4f6ddd3532 Add error handling tests for new send method 2011-07-28 22:41:53 +02:00
Thomas Adamcik
43f4f1537e Extract send to seperate method 2011-07-28 22:34:47 +02:00
Thomas Adamcik
13d4510e12 Rename send to send_queue in network.Connection 2011-07-28 22:28:17 +02:00
Thomas Adamcik
b2188f13cb Typo fixes 2011-07-25 17:41:02 +02:00
Thomas Adamcik
035af38b02 Merge branch 'develop' into feature/support-telnet
Conflicts:
	tests/utils/network/lineprotocol_test.py
2011-07-25 17:39:00 +02:00
Thomas Adamcik
9fe4674b36 Update on_received to handle that decode can fail 2011-07-25 01:24:19 +02:00
Thomas Adamcik
4049b23c3f Add concept of delimeter to complemend terminator in LineProtocol 2011-07-25 00:50:41 +02:00
Thomas Adamcik
451b52fde5 Make sure we prevent timeouts when in idle mode 2011-07-24 01:59:32 +02:00
Thomas Adamcik
6cf5deb216 Typo fix :) 2011-07-17 23:52:32 +02:00
Thomas Adamcik
23775dfe1a Fix up last comments regarding typo and more logging 2011-07-17 23:44:00 +02:00
Thomas Adamcik
d2a9e3d1ec Make send_callback respect flags from gobject 2011-07-17 00:33:15 +02:00
Thomas Adamcik
c773998fd8 Stop actor if decode or encode fails 2011-07-17 00:26:50 +02:00
Thomas Adamcik
1b46dade83 Note why source_remove return values are ignored 2011-07-15 00:54:14 +02:00
Thomas Adamcik
e6781135ba Doubled checked most network.Server/Connection/LineProtocol tests 2011-07-15 00:48:47 +02:00
Thomas Adamcik
805a6fefd0 Lint fixing 2011-07-14 23:14:51 +02:00
Thomas Adamcik
fe6e4a65f5 Fix syntax error 2011-07-14 11:09:04 +02:00
Thomas Adamcik
cf48faad98 Remove log_* method from LineProtocol 2011-07-13 23:57:00 +02:00
Thomas Adamcik
66a89918c8 Add LineProtocol tests 2011-07-13 23:11:28 +02:00
Thomas Adamcik
ee6f5a651b Try to prevent recursive calls to stop 2011-07-13 22:43:57 +02:00
Thomas Adamcik
a49855abfa Improve error handling in connection code 2011-07-13 22:32:35 +02:00
Thomas Adamcik
05b169930f Add missing stop explanation 2011-07-13 11:48:22 +02:00
Thomas Adamcik
b9286fb9ee Log why we are stopping 2011-07-12 03:48:02 +02:00
Thomas Adamcik
b5c6bc0442 Allways return true from recv_callback, rely on activly removing sources instead 2011-07-12 03:18:07 +02:00
Thomas Adamcik
8c9fc73550 Implement rest of connection tests 2011-07-12 03:15:30 +02:00
Thomas Adamcik
9b41eb17c5 Lint fixing 2011-07-11 23:55:33 +02:00
Thomas Adamcik
cef53b9e7d Cleanup of connection class 2011-07-11 19:07:22 +02:00
Thomas Adamcik
91270ef535 Refactor network.Server to improve testability 2011-07-11 18:53:49 +02:00
Thomas Adamcik
34cd3008d9 Extract gobject/network code to new Client class
This implies that the Server class is in charge of just listening and starting
up new clients. Clients are expected to run in the event loop thread, so they
only deal with minimal IO/network concerns. Each client has a protocol actor
that does the actual work.
2011-07-09 22:44:11 +02:00