testbot/TestAgent: Tweak the getfile RPC error handling.
Francois Gouget
fgouget at codeweavers.com
Thu Dec 6 14:01:02 CST 2012
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 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/testbot/src/testagentd/testagentd.c b/testbot/src/testagentd/testagentd.c
index a5b8e54..607c776 100644
--- a/testbot/src/testagentd/testagentd.c
+++ b/testbot/src/testagentd/testagentd.c
@@ -544,12 +544,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)
{
@@ -614,12 +614,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);
}
--
1.7.10.4
More information about the wine-patches
mailing list