From: Mark D. <ma...@ki...> - 2006-08-21 17:42:42
|
On Mon, 21 Aug 2006 07:39:32 -0400, Ethan Blanton wrote > Colin Barrett spake unto us the following wisdom: > > On Aug 20, 2006, at 7:16 PM, Mark Doliner wrote: > > > Ethan didn't like this (I think because it uses threads?), but his > > > reasons didn't really convince me. How do other people feel? It's > > > pretty easy to revert my change and go back to having lots of crazy > > > and confusing code, if people want. > > > > What exactly is his problem with using a thread? Threads are great; > > they only start to get hairy when you're passing data back and forth > > from one threadspace to another. But this type of task -- performing a > > blocking call without blocking the UI -- is the canonical, text book > > case for threads, and generally results in simple, easy to understand > > code -- assuming the library you're using is sane, of course ;) > > Actually, this is the textbook case where people who don't understand > threads *think* it's a textbook case for threads. In fact, the > _only_ time that threads make sense is when you have a huge amount > of shared data that both sides of the divide need to be able to > access rapidly. In cases such as this one, where the information to > be passed back and forth is very small, cooperating processes are a > huge win -- because memory faults in one process are isolated from > the other. With the thread scenario, a memory corruption bug in the > lookup thread can stomp data in the main process; in the cooperating > process scenario, it cannot. In fact, with a careful interface, a > complete failure in the lookup process affects only *one* thing in > the main procees; a single lookup fails. Memory faults... like, hardware problems or OS bugs? I kinda feel like we shouldn't really worry about designing Gaim so that it doesn't crash if there are memory faults. Besides, our memory use in the lookup process is orders of magnitude less than our memory use in the rest of Gaim. If we have a memory fault somewhere it's pretty unlikely that it's going to be in the DNS process. Having blocking DNS requests on (!Linux and !Windows) does concern me, though. Hopefully gethostbyname_r() will be usable on non-gnu systems. -Mark |