[Spice-devel,v2,06/19] Remove unused and obsolete main_channel_close

Submitted by Frediano Ziglio on Nov. 25, 2016, 2:52 p.m.

Details

Message ID dafdb9072df01e0f49b15b107203eff3be796a19.1480085518.git-series.fziglio@redhat.com
State New
Headers show
Series "Start cleaning objects on destruction" ( rev: 4 3 2 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Nov. 25, 2016, 2:52 p.m.
This function wrongly close the first client.
Wrongly as closing the file descriptor cause a dandling
file descriptor in the object potentially leading
to closing another file descriptor open later.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/main-channel.c | 10 ----------
 server/main-channel.h |  1 -
 2 files changed, 11 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/main-channel.c b/server/main-channel.c
index 6449c16..37b2f25 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -318,16 +318,6 @@  int main_channel_getpeername(MainChannel *main_chan, struct sockaddr *sa, sockle
         getpeername(red_channel_get_first_socket(RED_CHANNEL(main_chan)), sa, salen) : -1;
 }
 
-// TODO: ? shouldn't it disconnect all clients? or shutdown all main_channels?
-void main_channel_close(MainChannel *main_chan)
-{
-    int socketfd;
-
-    if (main_chan && (socketfd = red_channel_get_first_socket(RED_CHANNEL(main_chan))) != -1) {
-        close(socketfd);
-    }
-}
-
 MainChannel* main_channel_new(RedsState *reds)
 {
     // TODO: set the migration flag of the channel
diff --git a/server/main-channel.h b/server/main-channel.h
index 19beb7c..cb53fb4 100644
--- a/server/main-channel.h
+++ b/server/main-channel.h
@@ -61,7 +61,6 @@  RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t l
 MainChannelClient *main_channel_link(MainChannel *, RedClient *client,
      RedsStream *stream, uint32_t link_id, int migration, int num_common_caps,
      uint32_t *common_caps, int num_caps, uint32_t *caps);
-void main_channel_close(MainChannel *main_chan); // not destroy, just socket close
 void main_channel_push_mouse_mode(MainChannel *main_chan, int current_mode, int is_client_mouse_allowed);
 void main_channel_push_agent_connected(MainChannel *main_chan);
 void main_channel_push_agent_disconnected(MainChannel *main_chan);

Comments

On Fri, 2016-11-25 at 14:52 +0000, Frediano Ziglio wrote:
> This function wrongly close the first client.
> Wrongly as closing the file descriptor cause a dandling
> file descriptor in the object potentially leading
> to closing another file descriptor open later.
> 
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
> ---
>  server/main-channel.c | 10 ----------
>  server/main-channel.h |  1 -
>  2 files changed, 11 deletions(-)
> 
> diff --git a/server/main-channel.c b/server/main-channel.c
> index 6449c16..37b2f25 100644
> --- a/server/main-channel.c
> +++ b/server/main-channel.c
> @@ -318,16 +318,6 @@ int main_channel_getpeername(MainChannel
> *main_chan, struct sockaddr *sa, sockle
>          getpeername(red_channel_get_first_socket(RED_CHANNEL(main_c
> han)), sa, salen) : -1;
>  }
>  
> -// TODO: ? shouldn't it disconnect all clients? or shutdown all
> main_channels?
> -void main_channel_close(MainChannel *main_chan)
> -{
> -    int socketfd;
> -
> -    if (main_chan && (socketfd =
> red_channel_get_first_socket(RED_CHANNEL(main_chan))) != -1) {
> -        close(socketfd);
> -    }
> -}
> -
>  MainChannel* main_channel_new(RedsState *reds)
>  {
>      // TODO: set the migration flag of the channel
> diff --git a/server/main-channel.h b/server/main-channel.h
> index 19beb7c..cb53fb4 100644
> --- a/server/main-channel.h
> +++ b/server/main-channel.h
> @@ -61,7 +61,6 @@ RedClient
> *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t
> l
>  MainChannelClient *main_channel_link(MainChannel *, RedClient
> *client,
>       RedsStream *stream, uint32_t link_id, int migration, int
> num_common_caps,
>       uint32_t *common_caps, int num_caps, uint32_t *caps);
> -void main_channel_close(MainChannel *main_chan); // not destroy,
> just socket close
>  void main_channel_push_mouse_mode(MainChannel *main_chan, int
> current_mode, int is_client_mouse_allowed);
>  void main_channel_push_agent_connected(MainChannel *main_chan);
>  void main_channel_push_agent_disconnected(MainChannel *main_chan);