[JDEV] FreeBSD woes -OR- FreeBSD accept() issue
Keith Minkler
keith at digix.dyndns.org
Tue Dec 5 14:55:28 CST 2000
Hey jdev,
I've run into a problem with the 1.2/1.3+ server on FreeBSD, in io_select(1.2) and MIO(1.3)
it seems that the accept() call is blocking, even though the listening socket is set to non-blocking...
here is my code to set the sockets into non-blocking.. this is called for every socket that is put into MIO...
<from mio.c>
599 /* set the socket to non-blocking */
600 flags = fcntl(fd, F_GETFL, 0);
601 flags |= O_NONBLOCK;
602 fcntl(fd, F_SETFL, flags);
...
and here is the code that is calling accept()...
259 mio _mio_accept(mio m)
260 {
261 struct sockaddr_in sa;
262 size_t sa_size = sizeof(sa);
263 int fd;
264 mio new;
265
266 /* pull a socket off the accept queue */
267 fd = accept(m->fd, (struct sockaddr*)&sa, (int*)&sa_size);
268 if(fd <= 0)
269 {
270 /* this will try again eventually,
271 * if it's a blocking issue */
272 return NULL;
273 }
these code snippets were taken from the 1.3 server (HEAD CVS) but is similar in the 1.2 server, and neither work correctly on FreeBSD.. is there something here that I am doing wrong that is obvious (or not)?
if anyone could help out, i would very much appreciate it (along with our FreeBSD friends)
Thanks!
Keith Minkler
More information about the JDev
mailing list