Module: tools
Branch: master
Commit: 6dcdc3c5153cbc0a9d179624cb81b8198adf8fb4
URL: http://source.winehq.org/git/tools.git/?a=commit;h=6dcdc3c5153cbc0a9d179624…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Thu Dec 6 21:01:02 2012 +0100
testbot/TestAgent: Tweak the getfile RPC error handling.
Send the error message from the do_xxx() function like we do for all other RPCs rather than from the lower level send_file() function.
---
testbot/src/testagentd/testagentd.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/testbot/src/testagentd/testagentd.c b/testbot/src/testagentd/testagentd.c
index bb50d91..6d4589e 100644
--- a/testbot/src/testagentd/testagentd.c
+++ b/testbot/src/testagentd/testagentd.c
@@ -542,12 +542,12 @@ static int send_file(SOCKET client, int fd, const char* filename)
debug(" send_file(%s)\n", filename);
if (fstat(fd, &st))
{
- set_status(ST_ERROR, "unable to compute the size of '%s': %s", filename, strerror(errno));
- send_error(client);
+ set_status(ST_ERROR, "unable to get the size of '%s': %s", filename, strerror(errno));
return 0;
}
size = st.st_size;
- send_entry_header(client, 'd', size);
+ if (!send_entry_header(client, 'd', size))
+ return 0;
while (size)
{
@@ -612,12 +612,18 @@ static void do_getfile(SOCKET client)
}
else
{
- send_list_size(client, 1);
- send_file(client, fd, filename);
+ if (!send_list_size(client, 1) ||
+ !send_file(client, fd, filename))
+ {
+ /* If the file is not accessible then send_file() will fail and we
+ * can still salvage the connection by sending the error message
+ * in place of the file content. In all the other cases the
+ * connection is broken anyway which send_error() will deal with
+ * just fine.
+ */
+ send_error(client);
+ }
close(fd);
- /* Trying to report the status now would be pointless: either
- * the client got all the data fine or the connection is busted.
- */
}
free(filename);
}