--- aio.c.orig Fri Jul 22 05:33:52 2005 +++ aio.c Wed Jul 27 04:18:33 2005 @@ -25,8 +25,19 @@ /* The signal we'll use to signify aio done. */ #ifndef RT_SIGNAL_AIO +#ifndef SIGRTMIN +#define RT_SIGNAL_AIO NSIG +#else #define RT_SIGNAL_AIO (SIGRTMIN+3) #endif +#endif + +#ifndef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR +#ifdef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR +#define sival_int sigval_int +#define sival_ptr sigval_ptr +#endif +#endif /**************************************************************************** The buffer we keep around whilst an aio request is in process. @@ -131,7 +142,7 @@ { struct aio_extra *p; - for( p = aio_list_head; p; p = p->next) { + for(p = aio_list_head; p; p = p->next) { if (mid == p->mid) { return p; } @@ -155,7 +166,7 @@ static void signal_handler(int sig, siginfo_t *info, void *unused) { if (signals_received < AIO_PENDING_SIZE - 1) { - aio_pending_array[signals_received] = *(uint16 *)(info->si_value.sival_ptr); + aio_pending_array[signals_received] = (uint16)(info->si_value.sival_int); signals_received++; } /* Else signal is lost. */ sys_select_signal(RT_SIGNAL_AIO); @@ -181,7 +192,7 @@ ZERO_STRUCT(act); act.sa_sigaction = signal_handler; act.sa_flags = SA_SIGINFO; - sigemptyset( &act.sa_mask ); + sigemptyset(&act.sa_mask); if (sigaction(RT_SIGNAL_AIO, &act, NULL) != 0) { DEBUG(0,("Failed to setup RT_SIGNAL_AIO handler\n")); } @@ -239,7 +250,7 @@ SCVAL(aio_ex->outbuf,smb_vwv0,0xFF); /* Never a chained reply. */ a = &aio_ex->acb; - + /* Now set up the aio record for the read call. */ a->aio_fildes = fsp->fh->fd; @@ -499,6 +510,11 @@ static BOOL handle_aio_completed(struct aio_extra *aio_ex, int *perr) { int err; + + if(!aio_ex) { + DEBUG(3, ("handle_aio_completed: Non-existing aio_ex passed\n")); + return False; + } /* Ensure the operation has really completed. */ if (SMB_VFS_AIO_ERROR(aio_ex->fsp, &aio_ex->acb) == EINPROGRESS) { @@ -556,7 +572,7 @@ fsp = aio_ex->fsp; if (fsp == NULL) { /* file was closed whilst I/O was outstanding. Just ignore. */ - DEBUG( 3,( "process_aio_queue: file closed whilst aio outstanding.\n")); + DEBUG(3 ,( "process_aio_queue: file closed whilst aio outstanding.\n")); srv_cancel_sign_response(mid); continue; } @@ -615,7 +631,7 @@ return False; } - for( i = 0, aio_ex = aio_list_head; aio_ex; aio_ex = aio_ex->next) { + for(i = 0, aio_ex = aio_list_head; aio_ex; aio_ex = aio_ex->next) { if (aio_ex->fsp == fsp) { aiocb_list[i++] = &aio_ex->acb; } @@ -647,7 +663,7 @@ uint16 mid = *(uint16 *)aiocb_list[i]->aio_sigevent.sigev_value.sival_ptr; aio_ex = find_aio_ex(mid); - + if (!handle_aio_completed(aio_ex, &err)) { continue; }