Hi It's nice to have a thread sending the packets, so I would propose that we use one thread for every destination, that does all the sending. Every new packet that we want to send is just put on a queue in that thread. Nice and simple. Thinking more about it, I think the following would be applicate: We could have a couple of different packet types, like those that go to the server, and those that go to another user. For every destination, a new thread (of the above kind) would be spawned. The thread to the server would never be terminated, but the others would (we can't have hundreds of threads just lying about).
If a packets comes that wants to be sent to X and there happens to be a send to X in progress right now (in other words, there's already a thread for that receiver), the new packet is just added to that threads queue. This would mean that packets that go to the same receiver would get properly ordered. What do you think? I'm not really familiar with either licq or the icq protocols. So maybe there's some more needed ordering that I didn't know of? That would of course complicate my solution, and maybe make it inappropriate. Take care /Gabriel Btw, I'm not subscribed to the licq-main, so I can't crosspost. On Sun, 2002-07-28 at 02:36, Dennis Tenn wrote: > Hi Paul. > > And thank you. This information is better served on the developers list. > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > Dennis Tenn * There will always come a time > [EMAIL PROTECTED] * When your love will be tested > LICQ# 1457509 * Stand tall and rise to the occasion > http://www.licq.org/ * For only then will you grow strong. > http://www.ca.licq.org/ * -Anonymous > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > > ---------- Forwarded message ---------- > Date: Sun, 28 Jul 2002 02:01:05 +0200 (CEST) > From: Paul Boven <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: [Licq-main] Threads and Solaris 9 > > Hi everyone, > > As a follow-up to my earlier mails about being unable to go online with > a Solaris 9 (Sparc) machine, here are some findings: > > During the logon-process, SendEvent_Server 'forks' off a thread for > every new packet to be sent (see ProcessRunningEvent_Server_tep in > icqthreads.cpp). These threads (as far as I can see) only have to send > a packet to the server, and then they close. > > Because so many threads are spawned at the same time, there are no > guarantees as to the order of their execution. And although Solaris 8 > (and a lot of other Unices apparently) does happen to schedule them in > order of creation, Solaris 9 sometimes reverses this order. And this > might also happen on other platforms, especially multi-CPU machines. > Essentially this is a race-condition, and whether (or how often) it > causes a problem depends on the particular pthreads implementation, but > probably also on server load, network load and fase of the moon. > > I've tried a quick-and-dirty workaround, by adding an usleep(50000); > statement right after the thread creation (icqd.cpp line 956) to ensure > each thread has ample time to get scheduled and fire off it's packet. > This way I can successfully log onto ICQ once again. > > I see two 'proper' solutions to this problem: > > To not use a thread for merely sending off a packet, especially if > these have to be sent out in a specific order to not upset the > ICQ-server. One would only have to incorporate the functionality > within the ProcessRunningevent_Server_tep into SendEvent_Server, so no > thread gets forked off, to achieve this. > > Another solution might be to use some form of locking within the > threads. One way to implement this would be to keep track of the > sequence numbers already sent out, and only allow the thread to send > when it's packet would be next in line. > > I'm rather new to the Licq-code and to threads so I hope I'm not just > imagining things here. If however the more seasoned Licq-developers > agree with these findings, I'll be glad to try and help implement these > or other changes. > > Regards, Paul Boven. > -- > ------------------------------------------------------------------ > | "Rules exist to make you think before you break them" - Lu-Tze | > ------------------------------------------------------------------ > | Paul Boven <[EMAIL PROTECTED]> PE1NUT QRV 145.575 | > ------------------------------------------------------------------ > ~ ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Licq-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/licq-devel
