[JDEV] Non-blocking connect in mio.c

David Waite mass at akuma.org
Wed May 15 19:40:24 CDT 2002


These are not the functions you are looking for :-)

Most of the blocking system calls are actually handled by pth rather 
than directly by the system; pth does a non-blocking call, then shuffles 
values around to kick into another user-space thread. So the thread is 
blocked, but it is a user-space threading library which underneath uses 
non-blocking calls.

-David Waite

Michael Ngarimu wrote:

>Hi all,
>
>I'm trying to actually build (from source) and run jabberd 1.4.2. I seem
>to have a problem with s2s comms so I jumped into the source and strace.
>
>strace shows an attempt at a non-blocking connect....(see below)
>
>fcntl64(14, F_GETFL)                    = 0x802 (flags
>O_RDWR|O_NONBLOCK)
>connect(14, {sin_family=AF_INET, sin_port=htons(5269),
>sin_addr=inet_addr("208.245.212.108")}}, 16) = -1 EINPROGRESS (Operation
>now in progress)
>fcntl64(14, F_GETFL)                    = 0x802 (flags
>O_RDWR|O_NONBLOCK)
>
>Unfortunately, mio.c (_mio_connect) doesn't seem to allow for
>non-blocking connects!
>
>see mio.c(approx line 528)
>
>    if((*cd->cf)(new, (struct sockaddr*)&sa, sizeof sa) < 0)
>    {
>        if(cd->cb != NULL)
>            (*(mio_std_cb)cd->cb)(new, MIO_CLOSED, cd->cb_arg);
>        cd->connected = -1;
>
>        if(new->fd > 0)
>            close(new->fd);
>        mio_handlers_free(new->mh);
>        pool_free(p);
>        return;
>    }
>
>
>It calls connect (a few lines above an fcntl is done with flags |=
>O_NONBLOCK) and then checks for return -1, but within the if block
>doesn't checking for EINPROGRESS anywhere but instead just cleans up the
>socket.
>
>Surely, this must be an issue for people other than just me?
>
>"Help me Obi-Wan-Kenobi, you're my only hope!"
>
>
>_______________________________________________
>jdev mailing list
>jdev at jabber.org
>http://mailman.jabber.org/listinfo/jdev
>  
>






More information about the JDev mailing list