[squeak-dev] Help needed with select() socket function and signalhandlers in squeakVM

Mariano Martinez Peck marianopeck at gmail.com
Wed Jan 28 23:45:39 UTC 2009


David: Thanks for your help and time!

Norbert (openDBX author) just just tell me this is ok, but checking with
PQisBusy() again shouldn't be necessary. So, it was simplified and commited
to svn.

Actually now, it is like this:

#ifdef HAVE_SELECT
	if( timeout != NULL && PQisBusy( (PGconn*) handle->generic ) == 1 )
	{
		int fd, err;
		fd_set fds;

		if( ( fd = PQsocket( (PGconn*) handle->generic ) ) == -1 )

		{
			conn->errtype = -1;
			return -ODBX_ERR_BACKEND;
		}

		FD_ZERO( &fds );
		FD_SET( fd, &fds );

		while( ( err = select( fd + 1, &fds, NULL, NULL, timeout ) ) < 0 &&
errno == EINTR );

		switch( err )
		{
			case -1:
				return -ODBX_ERR_RESULT;
			case 0:
				return ODBX_RES_TIMEOUT;   /* timeout while waiting for a result */
		}
	}
#endif

I test it and works like a charm.

thanks again.

Mariano

On Wed, Jan 28, 2009 at 7:19 PM, David T. Lewis <lewis at mail.msen.com> wrote:

> On Wed, Jan 28, 2009 at 12:51:04AM -0200, Mariano Martinez Peck wrote:
> >
> > So, what I change openDBX code from this:
> >
> >         if( ( fd = PQsocket( (PGconn*) handle->generic ) ) == -1 )
> >         {
> >             conn->errtype = -1;
> >             return -ODBX_ERR_BACKEND;
> >         }
> >
> >         FD_ZERO( &fds );
> >         FD_SET( fd, &fds );
> >
> >         switch( select( fd + 1, &fds, NULL, NULL, timeout ) )
> >
> >
> >
> > to
> >
> >
> >     do {
> >
> >             if( ( fd = PQsocket( (PGconn*) handle->generic ) ) == -1 )
> >             {
> >                 conn->errtype = -1;
> >                 return -ODBX_ERR_BACKEND;
> >             }
> >
> >             FD_ZERO( &fds );
> >             FD_SET( fd, &fds );
> >
> >             rv = select( fd + 1, &fds, NULL, NULL, timeout );
> >
> >         } while ((rv == -1) && (errno == EINTR));
> >
> >         switch( rv )
> >
> >
> > And now It works perfect. It was difficult to reproduce because openDBX
> > tests where ok, but squeakDBX ones not. This is because of SqueakVM as
> you
> > explain me.
>
> Your change looks right to me.
>
> Dave
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090128/e5ab7597/attachment.htm


More information about the Squeak-dev mailing list