r9388 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r9387‎ | r9388 | r9389 >
Date:00:40, 11 June 2005
Author:kateturner
Status:old
Tags:
Comment:
kludge a workaround for 64-bit Linux sendfile() bug.
Modified paths:
  • /trunk/willow/src/lib/wnet/wnet.c (modified) (history)

Diff [purge]

Index: trunk/willow/src/lib/wnet/wnet.c
@@ -176,6 +176,7 @@
177177 fde->fde_epflags = 0;
178178 bzero(&fde->fde_readbuf, sizeof(fde->fde_readbuf));
179179 fde->fde_flags.open = 0;
 180+ bzero(&fde->fde_ev, sizeof(fde->fde_ev));
180181 }
181182
182183 int
@@ -219,7 +220,6 @@
220221 int fd;
221222 {
222223 struct fde *e = &fde_table[fd];
223 -
224224 wnet_register(fd, FDE_READ | FDE_WRITE, NULL, NULL);
225225 (void)close(e->fde_fd);
226226 if (e->fde_cdata)
@@ -256,8 +256,7 @@
257257 wb->wb_off = off;
258258
259259 e->fde_wdata = wb;
260 - if (!(flags & WNET_IMMED))
261 - wnet_register(e->fde_fd, FDE_WRITE, wnet_sendfile_do, e);
 260+ wnet_register(e->fde_fd, FDE_WRITE, wnet_sendfile_do, e);
262261 wnet_sendfile_do(e);
263262 return 0;
264263 }
@@ -286,8 +285,7 @@
287286
288287 e->fde_wdata = wb;
289288
290 - if (!(flags & WNET_IMMED))
291 - wnet_register(e->fde_fd, FDE_WRITE, wnet_write_do, e);
 289+ wnet_register(e->fde_fd, FDE_WRITE, wnet_write_do, e);
292290 wnet_write_do(e);
293291 }
294292
@@ -361,7 +359,24 @@
362360 #else
363361 # error i dont know how to invoke sendfile on this system
364362 #endif
 363+
 364+#ifdef __linux
 365+ /*
 366+ * The Linux sendfile() manual page says:
 367+ *
 368+ * When sendfile() returns, this variable will be set to the offset of the byte following the
 369+ * last byte that was read.
 370+ *
 371+ * However, this is not true on x86-64 when we are compiled as a 32-bit binary; the correct
 372+ * number of bytes is returned, but off is _not_ updated. So, we fudge it into working as we
 373+ * expect.
 374+ */
 375+ if (i > 0)
 376+ buf->wb_off += i;
 377+#endif
 378+
365379 buf->wb_size -= (buf->wb_off - origoff);
 380+ WDEBUG((WLOG_DEBUG, "sent %d bytes i=%d", (int)(buf->wb_off - origoff), i));
366381
367382 if (buf->wb_size == 0) {
368383 wnet_register(e->fde_fd, FDE_WRITE, NULL, NULL);

Status & tagging log