This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/5508] New: close does not work on sockets with pending aio


The following code demonstrates what I believe is the same issue as
was originally reported, but does so reading from stdin.  Once the
aio_read has begun and blocked, aio_cancel is unable to interrupt
it until some data does arrive to be read.

This means it is not possible to destroy the input buffer for a
read that you no longer care to get (or know you will never get)
since if some data does later arrive, the aio_handler function
will still be called.  If none ever does, you'll accrue a 'zombie'
thread for the remaining life of the process.  Neither of which
is a great situation...  so I do hope we can fix this.

Cheers,
Ron


$ gcc aio.c -o aio -lrt
$ ./aio
aww poo.


/* aio.c */
#include <stdio.h>
#include <unistd.h>
#include <aio.h>

static void aio_handler(union sigval data)
{
    printf("aio read\n");
}

int main()
{
    struct aiocb aio;
    char         buf;

    aio.aio_fildes  = STDIN_FILENO;
    aio.aio_offset  = 0;
    aio.aio_buf     = &buf;
    aio.aio_nbytes  = 1;
    aio.aio_reqprio = 0;
    aio.aio_sigevent.sigev_notify            = SIGEV_THREAD;
    aio.aio_sigevent.sigev_notify_function   = aio_handler;
    aio.aio_sigevent.sigev_notify_attributes = NULL;
    aio.aio_sigevent.sigev_value.sival_ptr   = NULL;

    aio_read( &aio );

    sleep(1);

    if( aio_cancel( STDIN_FILENO, &aio ) == AIO_NOTCANCELED )
        printf("aww poo.\n");
    else
        printf("woo hoo!\n");

    return 0;
}

-- 
           Summary: close does not work on sockets with pending aio
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: madcoder at debian dot org
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=5508

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]