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

Mariano Martinez Peck marianopeck at gmail.com
Sun Jan 25 22:50:35 UTC 2009


Hi people: We are developing SqueakDBX, an openDBX (
http://www.linuxnetworks.de/doc/index.php/OpenDBX) wrapper, that let us
communicate with major relational databases through a common API. OpenDBX is
a C library. SqueakDBX uses FFI to call those functions. Now, I am getting
an error with a select() invocation in that code.

This is a piece of the openDBX function with the problem:

static int pgsql_odbx_result( odbx_t* handle, odbx_result_t** result, struct
timeval* timeout, unsigned long chunk )
{

    struct pgconn* conn = (struct pgconn* ) handle->aux;

    if( timeout != NULL ) {
        fprintf( stdout, "timeval tv_sec value: %d\n", timeout->tv_sec );
        fprintf( stdout, "timeval tv_usec value: %d\n", timeout->tv_usec );
    } else {
        puts("El timeval is null");
    }

......

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

        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 ) )
        {
            case -1:
                printf( "Error with select function: %s\n", strerror( errno
) );
                return -ODBX_ERR_RESULT;
            case 0:
                return ODBX_RES_TIMEOUT;   /* timeout while waiting for a
result */
        }
    }
#endif


Now, I have a problem with select() invocation. This function returns -1.
And the printf of the errno (where select() stores the errors), says: "Error
with select function: Interrupted system call" which means I am getting a
EINTR error. If you see console, you can see something like this:

timeval tv_usec value: 0
timeval tv_sec value: 3
timeval tv_usec value: 0
timeval tv_sec value: 2
timeval tv_usec value: 996000
timeval tv_sec value: 3
timeval tv_usec value: 0
Error with select function: Interrupted system call


I asked Norbert (openDBX author) and he tell me exactly this:

"An interrupted system call is something very normal because signals can be
sent
at every time to the application, either by the system or by the user. I
guess, in the Squeak code there is some signal handler installed, which does
something if one of the defined signals arrive.

What I will do is to hide the consequences (returning an error) by looking
at
the error value and reenter the select call if the system call is
interrupted."

All I know is squeakVM is written it SLANG and then that's transformed to C.
So, squeakVM runs in C. So, there is where it can be a signal handler ? Is
there some way to change that from squeak (image) ?

I am still newbie so I really need help with this.

Thanks for the help in advance.

Mariano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090125/dc248fd7/attachment.htm


More information about the Squeak-dev mailing list