This is the mail archive of the libc-alpha@sources.redhat.com 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]

Re: lio_listio Problem


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;
}

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