[Mono-devel-list] XSP Listening Mechanism
Aaron Clauson
aza_rc at yahoo.com
Mon Sep 20 06:03:17 EDT 2004
Hi,
I have been playing around a bit with XSP on Linux and
Windows. I have no problems on Linux. On Windows I
have no problems if I use the mono runtime. On Windows
I have a problem if I use the Microsoft runtime.
I tracked the problem down to an infinite loop in the
method that listens for incoming socket connections. I
fixed the problem but was just curious if anyone knows
why the mechanism below is employed in the RunServer
method of the ApplicationServer class:
while (!stop){
w = wSockets.Count;
Socket.Select (wSockets, null, null, (w == 1) ? -1 :
1000 * 1000); // 1s
w = wSockets.Count;
<snip/>
wSockets.Clear ();
if (allSockets.Count == 1) {
wSockets.Add (listen_socket);
} else {
wSockets.AddRange (allSockets);
}
}
I may be missing something but I can't see how
wSockets.Count will ever not equal 1 up until the
first connection is established. This means the CPU
jumps to 100% until a connection is established!
Is there any reason not to just do:
while (!stop){
Socket clientSocket = listen_socket.Accept();
SetSocketOptions(clientSocket);
IWorker worker = webSource.CreateWorker(clientSocket,
this);
ThreadPool.QueueUserWorkItem (new WaitCallback
(worker.Run));
}
Aaron
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
More information about the Mono-devel-list
mailing list