/*
- * $Id: comm.cc,v 1.283 1998/08/18 19:13:59 wessels Exp $
+ * $Id: comm.cc,v 1.284 1998/08/18 22:42:17 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
state->handler_data = handler_data;
state->free_func = free_func;
cbdataLock(handler_data);
+#ifdef OPTIMISTIC_IO
+ commHandleWrite(fd, state);
+#else
commSetSelect(fd, COMM_SELECT_WRITE, commHandleWrite, state, 0);
+#endif
}
/* a wrapper around comm_write to allow for MemBuf to be comm_written in a snap */
/*
- * $Id: disk.cc,v 1.127 1998/08/18 21:15:43 wessels Exp $
+ * $Id: disk.cc,v 1.128 1998/08/18 22:42:18 wessels Exp $
*
* DEBUG: section 6 Disk I/O Routines
* AUTHOR: Harvest Derived
struct _fde_disk *fdd = &F->disk;
if (!fdd->write_q)
return;
+#ifdef OPTIMISTIC_IO
+ assert(!F->flags.calling_io_handler);
+#endif
debug(6, 3) ("diskHandleWrite: FD %d\n", fd);
/* We need to combine subsequent write requests after the first */
/* But only if we don't need to seek() in between them, ugh! */
if (fdd->wrt_handle_data != NULL)
cbdataUnlock(fdd->wrt_handle_data);
if (do_callback) {
+#ifdef OPTIMISTIC_IO
+ F->flags.calling_io_handler = 1;
+#endif
fdd->wrt_handle(fd, status, len, fdd->wrt_handle_data);
/*
* NOTE, this callback can close the FD, so we must
* not touch 'F', 'fdd', etc. after this.
*/
+#ifdef OPTIMISTIC_IO
+ F->flags.calling_io_handler = 0;
+#endif
return;
}
}
#if USE_ASYNC_IO
diskHandleWrite(fd, NULL);
#else
+#ifdef OPTIMISTIC_IO
+ if (F->flags.calling_io_handler)
+#endif
commSetSelect(fd, COMM_SELECT_WRITE, diskHandleWrite, NULL, 0);
+#ifdef OPTIMISTIC_IO
+ else
+ diskHandleWrite(fd, NULL);
+#endif
#endif
+#ifndef OPTIMISTIC_IO
F->flags.write_daemon = 1;
+#endif
}
}
fde *F = &fd_table[fd];
int len;
#endif
+#ifdef OPTIMISTIC_IO
+ assert(!F->flags.calling_io_handler);
+#endif /* OPTIMISTIC_IO */
#if USE_ASYNC_IO
aioRead(fd,
ctrl_dat->offset,
{
dread_ctrl *ctrl_dat = data;
int rc = DISK_OK;
+#ifdef OPTIMISTIC_IO
+ fde *F = &fd_table[fd];
+#endif /* OPTIMISTIC_IO */
errno = errcode;
if (len == -2 && errcode == -2) { /* Read cancelled - cleanup */
cbdataUnlock(ctrl_dat->client_data);
} else if (len == 0) {
rc = DISK_EOF;
}
+#ifdef OPTIMISTIC_IO
+ F->flags.calling_io_handler = 1;
+#endif /* OPTIMISTIC_IO */
if (cbdataValid(ctrl_dat->client_data))
ctrl_dat->handler(fd, ctrl_dat->buf, len, rc, ctrl_dat->client_data);
+#ifdef OPTIMISTIC_IO
+ F->flags.calling_io_handler = 0;
+#endif /* OPTIMISTIC_IO */
cbdataUnlock(ctrl_dat->client_data);
memFree(MEM_DREAD_CTRL, ctrl_dat);
}
file_read(int fd, char *buf, int req_len, off_t offset, DRCB * handler, void *client_data)
{
dread_ctrl *ctrl_dat;
+#ifdef OPTIMISTIC_IO
+ fde *F = &fd_table[fd];
+#endif /* OPTIMISTIC_IO */
assert(fd >= 0);
ctrl_dat = memAllocate(MEM_DREAD_CTRL);
ctrl_dat->fd = fd;
#if USE_ASYNC_IO
diskHandleRead(fd, ctrl_dat);
#else
+#ifndef OPTIMISTIC_IO
commSetSelect(fd,
COMM_SELECT_READ,
diskHandleRead,
ctrl_dat,
0);
+#else
+ if (F->flags.calling_io_handler)
+ commSetSelect(fd, COMM_SELECT_READ, diskHandleRead, ctrl_dat, 0);
+ else
+ diskHandleRead(fd, ctrl_dat);
+#endif /* OPTIMISTIC_IO */
#endif
return DISK_OK;
}
/*
- * $Id: http.cc,v 1.307 1998/08/17 16:44:07 wessels Exp $
+ * $Id: http.cc,v 1.308 1998/08/18 22:42:19 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
if (httpState->reply_hdr_state < 2)
httpProcessReplyHeader(httpState, buf, len);
storeAppend(entry, buf, len);
+#ifdef OPTIMISTIC_IO
+ if (entry->store_status == STORE_ABORTED) {
+ /*
+ * the above storeAppend() call could ABORT this entry,
+ * in that case, the server FD should already be closed.
+ * there's nothing for us to do.
+ */
+ (void) 0;
+ } else
+#endif
if (httpPconnTransferDone(httpState)) {
/* yes we have to clear all these! */
commSetDefer(fd, NULL, NULL);
/*
- * $Id: store_client.cc,v 1.36 1998/08/18 03:04:35 wessels Exp $
+ * $Id: store_client.cc,v 1.37 1998/08/18 22:42:22 wessels Exp $
*
* DEBUG: section 20 Storage Manager Client-Side Interface
* AUTHOR: Duane Wessels
{
MemObject *mem = sc->entry->mem_obj;
assert(sc->callback != NULL);
+#ifndef OPTIMISTIC_IO
if (mem->swap_hdr_sz == 0)
+#else
+ sc->flags.disk_io_pending = 1;
+ if (mem->swap_hdr_sz == 0) {
+#endif
file_read(sc->swapin_fd,
sc->copy_buf,
sc->copy_size,
0,
storeClientReadHeader,
sc);
+#ifndef OPTIMISTIC_IO
else {
+#else
+ } else {
+#endif
if (sc->entry->swap_status == SWAPOUT_WRITING)
assert(mem->swapout.done_offset > sc->copy_offset + mem->swap_hdr_sz);
file_read(sc->swapin_fd,
storeClientReadBody,
sc);
}
+#ifndef OPTIMISTIC_IO
sc->flags.disk_io_pending = 1;
+#endif
}
static void