This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: lio_listio Problem
- To: Andreas Jaeger <aj at suse dot de>
- Subject: Re: lio_listio Problem
- From: Ulrich Drepper <drepper at redhat dot com>
- Date: 25 Jul 2000 22:56:05 -0700
- Cc: libc-alpha Mailinglist <libc-alpha at sourceware dot cygnus dot com>, "Kevin Beard" <beardk at gatwick dot Geco-Prakla dot slb dot com>
- References: <u8hf9exb68.fsf@gromit.rhein-neckar.de>
- Reply-To: drepper at cygnus dot com (Ulrich Drepper)
Andreas Jaeger <aj@suse.de> writes:
> Kevin send me the appended test program (which I slightly modified).
The test program still contained a few bugs. I append below the
corrected version. But I was able to reproduce the problem and fixed
it in the CVS archive. Give it a try.
--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
#include <sys/utsname.h>
#include <stdlib.h>
#include <string.h>
#include <aio.h>
#define FILENAME "async.log"
#define ACCESS_MODE "O_RDWR | O_CREAT"
#define NUM_OF_AIOCBS 2
#define SIG_LISTIO_DONE (SIGRTMAX-9)
/*aiocb_t async0, async1;*/
struct aiocb *async_ctrl_blk[NUM_OF_AIOCBS];
char *out_data[NUM_OF_AIOCBS];
int counter;
int buf_switch = 0;
main()
{
for(counter=0; counter<NUM_OF_AIOCBS; counter++)
{
out_data[counter] = (char*)malloc(sizeof(char)+2);
sprintf(out_data[counter], "%1.1d\n", counter);
printf("%s", out_data[counter]);
}
for(counter=0; counter<NUM_OF_AIOCBS; counter++)
{
async_ctrl_blk[counter] = (struct aiocb*)malloc(sizeof(struct aiocb));
async_ctrl_blk[counter]->aio_fildes = open(FILENAME,O_RDWR | O_APPEND | O_CREAT, 0666);
async_ctrl_blk[counter]->aio_offset = 0;
async_ctrl_blk[counter]->aio_lio_opcode = LIO_WRITE;
async_ctrl_blk[counter]->aio_buf = out_data[counter];
async_ctrl_blk[counter]->aio_nbytes = sizeof(char)+2;
}
if (lio_listio(LIO_NOWAIT, async_ctrl_blk, NUM_OF_AIOCBS, NULL) < 0 )
perror("lio_listio");
aio_suspend(async_ctrl_blk, NUM_OF_AIOCBS, NULL);
return 0;
}