From: adrian <> Date: Mon, 21 Oct 2002 20:08:22 +0000 (+0000) Subject: Implement a new comm_write(). X-Git-Tag: SQUID_3_0_PRE1~601 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf3c0ee3c2820ad76445d82d7cfb7c2a10f32aec;p=thirdparty%2Fsquid.git Implement a new comm_write(). --- diff --git a/src/comm.cc b/src/comm.cc index cecbdab32e..75cfcb7c06 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.345 2002/10/21 14:00:02 adrian Exp $ + * $Id: comm.cc,v 1.346 2002/10/21 14:08:22 adrian Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -660,6 +660,32 @@ comm_write_try(int fd, void *data) commSetSelect(fd, COMM_SELECT_WRITE, comm_write_try, NULL, 0); } +/* + * Queue a write. handler/handler_data are called when the write fully + * completes, on error, or on file descriptor close. + */ +void +comm_write(int fd, char *buf, int size, IOWCB *handler, void *handler_data) +{ + /* Make sure we're not writing anything and we're not closing */ + assert(fdc_table[fd].active == 1); + assert(fdc_table[fd].write.handler == NULL); + assert(!fd_table[fd].flags.closing); + + /* Queue a read */ + fdc_table[fd].write.buf = buf; + fdc_table[fd].write.size = size; + fdc_table[fd].write.handler = handler; + fdc_table[fd].write.handler_data = handler_data; + fdc_table[fd].write.curofs = 0; + +#if OPTIMISTIC_IO + comm_write_try(fd, NULL); +#else + /* Register intrest in a FD read */ + commSetSelect(fd, COMM_SELECT_WRITE, comm_write_try, NULL, 0); +#endif +} /* Older stuff */ diff --git a/src/comm.h b/src/comm.h index 39c2379e31..ba765abf97 100644 --- a/src/comm.h +++ b/src/comm.h @@ -17,4 +17,6 @@ extern int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, extern int comm_udp_recv(int fd, void *buf, size_t len, int flags); extern ssize_t comm_udp_send(int s, const void *buf, size_t len, int flags); +extern void comm_write(int s, void *buf, size_t len, IOWCB *callback, void *callback_data); + #endif