[117] in 6.033-lab

home help back first fref pref prev next nref lref last post

Re: FD_ZERO and async.c

daemon@ATHENA.MIT.EDU (Kevin Fu)
Sun Feb 21 18:48:04 1999

To: 6.033-lab@MIT.EDU
Date: Sun, 21 Feb 1999 18:47:56 EST
From: Kevin Fu <fubob@MIT.EDU>

Here is a good question/answer that others may have.  Remember to
initialize your varibles (wfds, rfds) with FD_ZERO().

--------
Kevin E. Fu (fubob@mit.edu)
PGP key: finger fubob@monk.mit.edu

------- Forwarded Message
To: Ivan D Nestlerode <nestler@MIT.EDU>
Cc: 6.033-lab-tas@MIT.EDU
Subject: Re: FD_ZERO and async.c 
Date: Sun, 21 Feb 1999 12:25:39 EST
From: Jeffrey Hu <jhu@MIT.EDU>


>The only functions in async.c (besides make_async) are cb_add, cb_free,
>and cb_check. The fd_set's rfds and wfds need to be cleared with FD_ZERO
>at some point before they are used. Where to I put this call?
>
>It isn't appropriate to put in in any of the 3 cb_* functions because
>I don't want to be erasing file descriptors from the sets once the program
>is up and running. I guess you could make some kind of static integer flag
>(initially zero) that is checked in cb_add. If the flag is off, FD_ZERO
>is called before anything and the flag is turned on. If the flag is on,
>FD_ZERO wouldn't be called.
>
>This seems like a bit of a hack. Is this really what we're supposed to do?

To answer your question correctly, we should probably tell you to put
FD_ZERO in a new callback function that we would call cb_init.

However, you are right, that you wouldn't want to be calling FD_ZERO
in one of the three callback functions.

This is a minor initialization that we neglected to consider.  Just
put FD_ZERO in the initialization of your proxy, or go ahead and 
implement a cb_init that calls FD_ZERO.

				Jeff

------- End of Forwarded Message


home help back first fref pref prev next nref lref last post