in reply to Re^4: Thread weirdness
in thread Thread weirdness

I've looked through the code you (finally) posted. I think at least part of the problem is that $Sock is not declared as shared and you will thus have problems with potential race conditions, at least as far as I understand the Perl threading model. I would restrict all communication within your program to Thread::Queues and have one (and only one) thread specialized to talking to the server and listening to replies. That is, I would turn your send_msg function into one that stuffs the message into a queue, and at the other end of that queue have a thread that does nothing but listen to that queue and forward the things to the server.

Ideally, no background process would do direct communication with the irc server, they would all deliver their results to the server thread which then handles the communication. You will need send rate limiting anyway so your bot does not get kicked off the server for flooding it.

Personally, I would look towards AnyEvent::IRC or any of the other IRC frameworks though.

Replies are listed 'Best First'.
Re^6: Thread weirdness
by BrowserUk (Patriarch) on Sep 25, 2008 at 14:41 UTC