home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!ub!rutgers!cbmvax!cbmehq!cbmger!edohwg!heinz
- From: heinz@edohwg.adsp.sub.org (Heinz Wrobel)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Enough talk. FILE: server.c
- Message-ID: <heinz.060l@edohwg.adsp.sub.org>
- Date: 8 Jan 93 19:20:39 GMT
- References: <C0IyF5.9Gv@usenet.ucs.indiana.edu>
- Organization: Edotronik GmbH
- Lines: 44
-
- In article <C0IyF5.9Gv@usenet.ucs.indiana.edu> shulick@navajo.ucs.indiana.edu (Sam Hulick) writes:
- > Forbid();
- > myport = FindPort("Foobar!"); /*Is the server already running..? */
- > Permit();
-
- You shouldn't Permit() here. You delay it depending on myport until after
- AddPort() or some other server could get in your way.
-
- > while (!done) {
- > WaitPort(myport); /* Wait for an incoming message. */
- > while ((msg = (struct FooMsg *)GetMsg(myport))) /* Got one...! */
- > {
-
- Hmm. There is no ReplyMsg() or FreeMem or any cleanup like that for msg!
-
- > if (!(win = (struct Window *)OpenWindow(&newwin)))
- > {
- > Alert(AN_OpenWindow);
- > exit(0);
-
- Hmmm. You quit without even trying to clean up behind yourself. Not nice.
- Leaves lots of memory and a non functional port around.
-
- >void shutdown(struct MsgPort *victim)
- >{
- > FlushPort(victim); /* Empty the queue (see func below) */
- > RemPort(victim); /* We're no longer public.. */
-
- In between FlushPort() and RemPort() somebody could add new messages. You
- should be protecting yourself. safe sex ;^) :-)
-
- > // Amiga 3000 ___ \ Sam Hulick: shulick@indiana.edu (NeXTmail OK!)
-
- While all of this doesn't help you right now, you should "fix" the code
- first and make it as "clean" and nice as possible. Then check the results
- again with mungwall and munglist.
-
- --
- Heinz Wrobel, Edotronik GmbH (ECG018)
- FAX +49 89 850 51 25 / TEL +49 89 850 25 20 (HOME!&VOICE, sometimes...)
- Path: cbmehq!cbmger!edohwg!heinz@cbmvax.commodore.com
- "It's good to have a mouse, it's faster if you can do without one..."
- "He who doesn't develop with an A2024 doesn't know about font independent
- user interfaces..."
-