On 10/18/06, Robert Schuster <theBohemian@xxxxxxx> wrote:
do { ret = cpnio_accept (fd, (struct sockaddr *) &addr, &alen); } while (ret == -1); if (ret == -1) { if (EWOULDBLOCK != tmp_errno && EAGAIN != tmp_errno) JCL_ThrowException (env, "java/net/SocketException", strerror (tmp_errno)); } return ret; tmp_errno is an int which is set to 0 in the beginning.
Obvious point. The check at the end of the loop is completely redundant as you can never exit the loop with ret == -1. You only want to loop if it was an EINTR but no Java-interrupt. Currently this code loops for all errors apart from Java-interrupt. This is wrong. For example it will enter a never-ending loop if accept returned EBADF, i.e. if the socket had closed for some reason. A non-blocking socket will also spin while there was no connection present. Rob.