[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] sendfile on solaris
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] sendfile on solaris
- From: Michael Herf <herf@xxxxxxxxx>
- Date: Thu, 11 Aug 2011 14:16:10 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Thu, 11 Aug 2011 17:16:44 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=MtaLUreIEzsZ920bkceVSxjqmHydggZh4C7lGceBmIk=; b=vJlJLxzh+iqbKKNTBF2mkWjJorZ4D9AkSKE0Ib8occ4ks9X6c+XkwuDrf6K4YHAQ0X dZHnyHi9Z6Ba+VEbWdcU8Cp8xjVa+VjMDAyq6BIYdGDLBsSMv0uQL9sJQXGYbVIfuUSb 3D9bSCzkdQ0yFeXJ3gjshbyhvKDzp7JXakPIA=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
- User-agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0
In addition to my note about 64-bit offsets earlier:
Solaris sendfile seems to fail when sending moderately large (<1GB)
files. Not a 32/64 problem, but a buffer problem.
Anyone else ever try this? It is definitely broken in http-server.c.
It seems to be broken in the following way:
When sendfile sends partial data (EAGAIN, would block), "res" is
always -1, rather than the amount sent.
Here's a patch that reads from the "offset" pointer instead to
discover what was sent. This seems to work:
--- buffer.c 2010-12-16 10:05:27.000000000 -0800
+++ ../libevent/buffer.c 2011-08-11 14:13:42.288328799 -0700
@@ -2262,11 +2262,18 @@
}
return (res);
#elif defined(SENDFILE_IS_SOLARIS)
- res = sendfile(fd, info->fd, &offset, chain->off);
- if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) {
+
+ off_t offset0 = offset;
+ res = sendfile(fd, info->fd, &offset, chain->off);
+
+ if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) {
+ if (offset - offset0) {
+ return offset - offset0;
+ }
/* if this is EAGAIN or EINTR return 0; otherwise, -1 */
return (0);
- }
+ }
+
return (res);
#endif
}
mike
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.