From: adrian <> Date: Sun, 12 Aug 2001 21:29:58 +0000 (+0000) Subject: * Add support for the async write op X-Git-Tag: SQUID_3_0_PRE1~1445 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd1ee1e651c0456021274dc194c11b6152e0fba7;p=thirdparty%2Fsquid.git * Add support for the async write op * Make sure we call freefunc() on the buffer in the write op case --- diff --git a/src/fs/coss/async_io.cc b/src/fs/coss/async_io.cc index 55d46cf4d8..0f6045000f 100644 --- a/src/fs/coss/async_io.cc +++ b/src/fs/coss/async_io.cc @@ -11,7 +11,7 @@ * supports are read/write, and since COSS works on a single file * per storedir it should work just fine. * - * $Id: async_io.cc,v 1.3 2001/08/12 14:58:24 adrian Exp $ + * $Id: async_io.cc,v 1.4 2001/08/12 15:29:58 adrian Exp $ */ #include "squid.h" @@ -105,13 +105,47 @@ void a_file_write(async_queue_t *q, int fd, off_t offset, void *buf, int len, DWCB *callback, void *data, FREE *freefunc) { + int slot; + async_queue_entry_t *qe; + assert(q->aq_state == AQ_STATE_SETUP); +#if 0 file_write(fd, offset, buf, len, callback, data, freefunc); +#endif /* Find a free slot */ + slot = a_file_findslot(q); + if (slot < 0) { /* No free slot? Callback error, and return */ + fatal("Aiee! out of aiocb slots!\n"); + } + /* Mark slot as ours */ + qe = &q->aq_queue[slot]; + qe->aq_e_state = AQ_ENTRY_USED; + qe->aq_e_callback.write = callback; + qe->aq_e_callback_data = data; + qe->aq_e_type = AQ_ENTRY_WRITE; + qe->aq_e_free = freefunc; + qe->aq_e_buf = buf; + qe->aq_e_fd = fd; + + qe->aq_e_aiocb.aio_fildes = fd; + qe->aq_e_aiocb.aio_nbytes = len; + qe->aq_e_aiocb.aio_offset = offset; + qe->aq_e_aiocb.aio_buf = buf; + + /* Account */ + q->aq_numpending++; + + /* Lock */ + cbdataLock(data); + /* Initiate aio */ + if (aio_write(&qe->aq_e_aiocb) < 0) { + debug(1, 1)("Aiee! aio_read() returned error (%d)!\n", errno); + assert(1==0); + } } @@ -175,6 +209,8 @@ a_file_callback(async_queue_t *q) wc(fd, reterr, retval, callback_data); } cbdataUnlock(callback_data); + if (type == AQ_ENTRY_WRITE && freefunc) + freefunc(buf); } }