qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] A question about this commit "char: convert from GIOChannel to QIOChannel"
@ 2016-10-17 13:02 wangyunjian
  2016-10-17 13:20 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: wangyunjian @ 2016-10-17 13:02 UTC (permalink / raw)
  To: berrange@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org; +Cc: caihe

Commit 9894dc0cdcc397ee5b26370bc53da6d360a363c2 “char: convert from GIOChannel to QIOChannel”,
about the below code segment:

・・・ ・・・
@@ -3107,22 +2965,16 @@ static void tcp_chr_close(CharDriverState *chr)
         s->reconnect_timer = 0;
     }
     qapi_free_SocketAddress(s->addr);
-    if (s->fd >= 0) {
-        remove_fd_in_watch(chr);
-        if (s->chan) {
-            g_io_channel_unref(s->chan);
-        }
-        closesocket(s->fd);
+    remove_fd_in_watch(chr);
+    if (s->ioc) {
+        object_unref(OBJECT(s->ioc));
     }
-    if (s->listen_fd >= 0) {
-        if (s->listen_tag) {
-            g_source_remove(s->listen_tag);
-            s->listen_tag = 0;
-        }
-        if (s->listen_chan) {
-            g_io_channel_unref(s->listen_chan);
-        }
-        closesocket(s->listen_fd);
+    if (s->listen_tag) {
+        g_source_remove(s->listen_tag);
+        s->listen_tag = 0;
+    }
+    if (s->listen_ioc) {
+        object_unref(OBJECT(s->listen_ioc));
     }
・・・ ・・・
@@ -2544,17 +2496,16 @@ static void udp_chr_close(CharDriverState *chr)
     NetCharDriver *s = chr->opaque;
     remove_fd_in_watch(chr);
-    if (s->chan) {
-        g_io_channel_unref(s->chan);
-        closesocket(s->fd);
+    if (s->ioc) {
+        object_unref(OBJECT(s->ioc));
     }
     g_free(s);
     qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}


The old version will call closesocket when tcp_chr_close and udp_chr_close are called. But the new version will not call closesocket.


This can bring to a socket leak?



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-17 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-17 13:02 [Qemu-devel] A question about this commit "char: convert from GIOChannel to QIOChannel" wangyunjian
2016-10-17 13:20 ` Paolo Bonzini
2016-10-17 14:17   ` wangyunjian
2016-10-17 14:47     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).