Message ID | 1331557893-30806-4-git-send-email-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
On 03/12/2012 05:11 PM, Marc-André Lureau wrote: > --- > migration-tcp.c | 9 +++++---- > migration-unix.c | 9 +++++---- > savevm.c | 1 + > 3 files changed, 11 insertions(+), 8 deletions(-) > > diff --git a/migration-tcp.c b/migration-tcp.c > index f567898..056867c 100644 > --- a/migration-tcp.c > +++ b/migration-tcp.c > @@ -137,7 +137,7 @@ static void tcp_accept_incoming_migration(void *opaque) > > if (c == -1) { > fprintf(stderr, "could not accept migration connection\n"); > - goto out2; > + goto out; > } > > f = qemu_fopen_socket(c, "r"); > @@ -145,12 +145,13 @@ static void tcp_accept_incoming_migration(void *opaque) > fprintf(stderr, "could not qemu_fopen socket\n"); > goto out; > } > - > + c = -1; > process_incoming_migration(f); > qemu_fclose(f); > + > out: > - close(c); > -out2: > + if (c != -1) > + close(c); > qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL); > close(s); > } > diff --git a/migration-unix.c b/migration-unix.c > index 3928f4c..0a3a076 100644 > --- a/migration-unix.c > +++ b/migration-unix.c > @@ -134,7 +134,7 @@ static void unix_accept_incoming_migration(void *opaque) > > if (c == -1) { > fprintf(stderr, "could not accept migration connection\n"); > - goto out2; > + goto out; > } > > f = qemu_fopen_socket(c, "r"); > @@ -142,12 +142,13 @@ static void unix_accept_incoming_migration(void *opaque) > fprintf(stderr, "could not qemu_fopen socket\n"); > goto out; > } > - > + c = -1; > process_incoming_migration(f); > qemu_fclose(f); > + > out: > - close(c); > -out2: > + if (c != -1) > + close(c); > qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL); > close(s); > } As I understand you want to close(c) only if (f == NULL) succeeded, and do not want to do this in normal function path? It looks strange (I'm not an expert though), but if this is actually correct, than you can do this in "if (f == NULL)" body, without checking if (c != -1).
diff --git a/migration-tcp.c b/migration-tcp.c index f567898..056867c 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -137,7 +137,7 @@ static void tcp_accept_incoming_migration(void *opaque) if (c == -1) { fprintf(stderr, "could not accept migration connection\n"); - goto out2; + goto out; } f = qemu_fopen_socket(c, "r"); @@ -145,12 +145,13 @@ static void tcp_accept_incoming_migration(void *opaque) fprintf(stderr, "could not qemu_fopen socket\n"); goto out; } - + c = -1; process_incoming_migration(f); qemu_fclose(f); + out: - close(c); -out2: + if (c != -1) + close(c); qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL); close(s); } diff --git a/migration-unix.c b/migration-unix.c index 3928f4c..0a3a076 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -134,7 +134,7 @@ static void unix_accept_incoming_migration(void *opaque) if (c == -1) { fprintf(stderr, "could not accept migration connection\n"); - goto out2; + goto out; } f = qemu_fopen_socket(c, "r"); @@ -142,12 +142,13 @@ static void unix_accept_incoming_migration(void *opaque) fprintf(stderr, "could not qemu_fopen socket\n"); goto out; } - + c = -1; process_incoming_migration(f); qemu_fclose(f); + out: - close(c); -out2: + if (c != -1) + close(c); qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL); close(s); } diff --git a/savevm.c b/savevm.c index 4171ebf..b6a690d 100644 --- a/savevm.c +++ b/savevm.c @@ -223,6 +223,7 @@ static int socket_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int static int socket_close(void *opaque) { QEMUFileSocket *s = opaque; + close(s->fd); g_free(s); return 0; }