aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-12-07 14:46:26 +0100
committerLukas Larsson <[email protected]>2011-12-07 19:19:17 +0100
commit1137c0a08b25ab5e38286260f0b7c51ba015afbb (patch)
tree4258119045dc70037e41fd55e16cdd55724c53a9 /erts/emulator
parentf34a89e0c0cc92226d5fe3fb257c62251068392b (diff)
downloadotp-1137c0a08b25ab5e38286260f0b7c51ba015afbb.tar.gz
otp-1137c0a08b25ab5e38286260f0b7c51ba015afbb.tar.bz2
otp-1137c0a08b25ab5e38286260f0b7c51ba015afbb.zip
Return {error,closed} from sendfile if closed
If the socket is closed by the remote end, sendfile now returns {error,closed}.
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/drivers/common/efile_drv.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/erts/emulator/drivers/common/efile_drv.c b/erts/emulator/drivers/common/efile_drv.c
index 5c52b99348..32914d3b22 100644
--- a/erts/emulator/drivers/common/efile_drv.c
+++ b/erts/emulator/drivers/common/efile_drv.c
@@ -799,7 +799,16 @@ static void reply_Uint_posix_error(file_descriptor *desc, Uint num,
driver_output2(desc->port, response, t-response, NULL, 0);
}
+static void reply_string_error(file_descriptor *desc, char* str) {
+ char response[256]; /* Response buffer. */
+ char* s;
+ char* t;
+ response[0] = FILE_RESP_ERROR;
+ for (s = str, t = response+1; *s; s++, t++)
+ *t = tolower(*s);
+ driver_output2(desc->port, response, t-response, NULL, 0);
+}
static int reply_error(file_descriptor *desc,
Efile_error *errInfo) /* The error codes. */
@@ -2208,7 +2217,12 @@ file_async_ready(ErlDrvData e, ErlDrvThreadData data)
case FILE_SENDFILE:
if (d->result_ok == -1) {
desc->sendfile_state = not_sending;
- reply_error(desc, &d->errInfo);
+ if (d->errInfo.posix_errno == ECONNRESET ||
+ d->errInfo.posix_errno == ENOTCONN ||
+ d->errInfo.posix_errno == EPIPE)
+ reply_string_error(desc,"closed");
+ else
+ reply_error(desc, &d->errInfo);
if (sys_info.async_threads != 0) {
SET_NONBLOCKING(d->c.sendfile.out_fd);
free_sendfile(data);