Author: adrian.chadd
Date: Fri May 1 01:36:14 2009
New Revision: 14020
Modified:
branches/LUSCA_HEAD/libasyncio/aiops.c
branches/LUSCA_HEAD/libasyncio/aiops.h
branches/LUSCA_HEAD/libasyncio/async_io.c
Log:
Manually enforce that the offset -must- be specified to the async IO
routines.
This needs to be documented better.
It is a change from the previous async IO behaviour (pre-COSS) when
offset/whence
were simply passed to the lseek() call before read/write ; but this had to
change
to support atomic concurrent file operations on the same file descriptor.
Modified: branches/LUSCA_HEAD/libasyncio/aiops.c
==============================================================================
--- branches/LUSCA_HEAD/libasyncio/aiops.c (original)
+++ branches/LUSCA_HEAD/libasyncio/aiops.c Fri May 1 01:36:14 2009
@@ -578,7 +578,7 @@
* @return 0 on success, -1 on failure.
*/
int
-squidaio_read(int fd, char *bufp, int bufs, off_t offset, int whence,
squidaio_result_t * resultp)
+squidaio_read(int fd, char *bufp, int bufs, off_t offset,
squidaio_result_t * resultp)
{
squidaio_request_t *requestp;
@@ -587,7 +587,6 @@
requestp->bufferp = bufp;
requestp->buflen = bufs;
requestp->offset = offset;
- requestp->whence = whence;
requestp->resultp = resultp;
requestp->request_type = _AIO_OP_READ;
requestp->cancelled = 0;
@@ -611,7 +610,7 @@
int
-squidaio_write(int fd, char *bufp, int bufs, off_t offset, int whence,
squidaio_result_t * resultp)
+squidaio_write(int fd, char *bufp, int bufs, off_t offset,
squidaio_result_t * resultp)
{
squidaio_request_t *requestp;
@@ -620,7 +619,6 @@
requestp->bufferp = bufp;
requestp->buflen = bufs;
requestp->offset = offset;
- requestp->whence = whence;
requestp->resultp = resultp;
requestp->request_type = _AIO_OP_WRITE;
requestp->cancelled = 0;
Modified: branches/LUSCA_HEAD/libasyncio/aiops.h
==============================================================================
--- branches/LUSCA_HEAD/libasyncio/aiops.h (original)
+++ branches/LUSCA_HEAD/libasyncio/aiops.h Fri May 1 01:36:14 2009
@@ -43,7 +43,6 @@
char *bufferp;
int buflen;
off_t offset;
- int whence;
int ret;
int err;
struct stat *tmpstatp;
@@ -75,8 +74,8 @@
void squidaio_shutdown(void);
int squidaio_cancel(squidaio_result_t *);
int squidaio_open(const char *, int, mode_t, squidaio_result_t *);
-int squidaio_read(int, char *, int, off_t, int, squidaio_result_t *);
-int squidaio_write(int, char *, int, off_t, int, squidaio_result_t *);
+int squidaio_read(int, char *, int, off_t, squidaio_result_t *);
+int squidaio_write(int, char *, int, off_t, squidaio_result_t *);
int squidaio_close(int, squidaio_result_t *);
int squidaio_stat(const char *, struct stat *, squidaio_result_t *);
int squidaio_unlink(const char *, squidaio_result_t *);
Modified: branches/LUSCA_HEAD/libasyncio/async_io.c
==============================================================================
--- branches/LUSCA_HEAD/libasyncio/async_io.c (original)
+++ branches/LUSCA_HEAD/libasyncio/async_io.c Fri May 1 01:36:14 2009
@@ -298,7 +298,6 @@
aioWrite(int fd, off_t offset, char *bufp, int len, AIOCB * callback, void
*callback_data, FREE * free_func)
{
squidaio_ctrl_t *ctrlp;
- int seekmode;
assert(initialised);
squidaio_counts.write++;
@@ -309,15 +308,10 @@
ctrlp->operation = _AIO_WRITE;
ctrlp->bufp = bufp;
ctrlp->free_func = free_func;
- if (offset >= 0)
- seekmode = SEEK_SET;
- else {
- seekmode = SEEK_END;
- offset = 0;
- }
+ assert(offset >= 0);
cbdataLock(callback_data);
ctrlp->result.data = ctrlp;
- squidaio_write(fd, bufp, len, offset, seekmode, &ctrlp->result);
+ squidaio_write(fd, bufp, len, offset, &ctrlp->result);
dlinkAdd(ctrlp, &ctrlp->node, &used_list);
} /* aioWrite */
@@ -326,7 +320,6 @@
aioRead(int fd, off_t offset, int len, AIOCB * callback, void
*callback_data)
{
squidaio_ctrl_t *ctrlp;
- int seekmode;
assert(initialised);
squidaio_counts.read++;
@@ -337,15 +330,10 @@
ctrlp->operation = _AIO_READ;
ctrlp->len = len;
ctrlp->bufp = xmalloc(len);
- if (offset >= 0)
- seekmode = SEEK_SET;
- else {
- seekmode = SEEK_CUR;
- offset = 0;
- }
+ assert(offset >= 0);
cbdataLock(callback_data);
ctrlp->result.data = ctrlp;
- squidaio_read(fd, ctrlp->bufp, len, offset, seekmode, &ctrlp->result);
+ squidaio_read(fd, ctrlp->bufp, len, offset, &ctrlp->result);
dlinkAdd(ctrlp, &ctrlp->node, &used_list);
return;
} /* aioRead */
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---