listener tcp: Remove lock

This commit is contained in:
Hylke Bons 2012-07-03 20:27:42 +02:00
parent 119df4f0eb
commit 78b0069a99

View file

@ -26,7 +26,6 @@ namespace SparkleLib {
private Socket socket;
private Thread thread;
private Object socket_lock = new Object ();
private bool is_connected = false;
private bool is_connecting = false;
private DateTime last_ping = DateTime.Now;
@ -40,7 +39,6 @@ namespace SparkleLib {
public override bool IsConnected {
get {
lock (this.socket_lock)
return this.is_connected;
}
}
@ -48,7 +46,6 @@ namespace SparkleLib {
public override bool IsConnecting {
get {
lock (this.socket_lock)
return this.is_connecting;
}
}
@ -67,7 +64,6 @@ namespace SparkleLib {
port = 80;
try {
lock (this.socket_lock) {
this.socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) {
ReceiveTimeout = 5 * 1000,
SendTimeout = 5 * 1000
@ -84,7 +80,6 @@ namespace SparkleLib {
// Subscribe to channels of interest to us
foreach (string channel in base.channels)
AlsoListenToInternal (channel);
}
} catch (SocketException e) {
this.is_connected = false;
@ -119,7 +114,6 @@ namespace SparkleLib {
byte [] ping_bytes = Encoding.UTF8.GetBytes ("ping\n");
byte [] pong_bytes = new byte [4096];
lock (this.socket_lock)
this.socket.Send (ping_bytes);
if (this.socket.Receive (pong_bytes) < 1)
@ -173,7 +167,6 @@ namespace SparkleLib {
}
if (this.socket.Available > 0)
lock (this.socket_lock)
bytes_read = this.socket.Receive (bytes);
// Parse the received message
@ -207,9 +200,7 @@ namespace SparkleLib {
string to_send = "subscribe " + folder_identifier + "\n";
try {
lock (this.socket_lock)
this.socket.Send (Encoding.UTF8.GetBytes (to_send));
this.last_ping = DateTime.Now;
} catch (Exception e) {
@ -227,7 +218,6 @@ namespace SparkleLib {
+ " " + announcement.Message + "\n";
try {
lock (this.socket_lock)
if (this.socket != null)
this.socket.Send (Encoding.UTF8.GetBytes (to_send));