On 01/16/2014 06:15 PM, Daniel P. Berrange wrote:
On Wed, Jan 08, 2014 at 05:12:54PM +0800, Lei Li wrote:
Signed-off-by: Lei Li <li...@linux.vnet.ibm.com>
---
fsdev/virtfs-proxy-helper.c | 51 ++++++------------------------------------
hw/9pfs/virtio-9p-proxy.h | 5 ----
2 files changed, 8 insertions(+), 48 deletions(-)
diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index 713a7b2..44c6e61 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
-static int send_fd(int sockfd, int fd)
-{
...
- /* No ancillary data on error */
- if (fd < 0) {
- /* fd is really negative errno if the request failed */
- data = fd;
- } else {
- data = V9FS_FD_VALID;
The way data is initialized here...
@@ -784,11 +743,17 @@ static void usage(char *prog)
static int process_reply(int sock, int type,
struct iovec *out_iovec, int retval)
{
+ int data = V9FS_FD_VALID;
Doesn't match what you do here.
Well, it looks like it does not match the original order,
because the 'data' has to be passed to the common methods by
the parameter *buf first, as there would be different data
value set for the check by those callers. But the logical
is the same:
if the passed_fd is negative, 'data' will be set to the
negative fd; otherwise it'll be the check value.
+
switch (type) {
case T_OPEN:
case T_CREATE:
- if (send_fd(sock, retval) < 0) {
+ if (qemu_send_with_fd(sock, retval, &data, sizeof(data)) < 0) {
return -1;
+ } else {
+ if (retval >= 0) {
+ close(retval);
+ }
}
break;
case T_MKNOD:
Regards,
Daniel
--
Lei