common: improve G_IO_ERR | G_IO_HUP handling 61/261261/1 accepted/tizen/unified/20210715.124015 submit/tizen/20210714.103132
authorINSUN PYO <insun.pyo@samsung.com>
Wed, 14 Jul 2021 05:46:29 +0000 (14:46 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Wed, 14 Jul 2021 05:46:29 +0000 (14:46 +0900)
Change-Id: I00f7434b06a6580f9e19e780d028466ce6085e5c

src/shared/fd_handler.c

index e9927a2..fb65878 100644 (file)
@@ -73,13 +73,12 @@ static gboolean channel_changed(GIOChannel *source,
        if (h->fd != g_io_channel_unix_get_fd(source))
                return TRUE;
 
+       if (condition & (G_IO_ERR | G_IO_HUP))
+               _E("GIOChannel receives G_IO_ERR|G_IO_HUP fd = %d condition = %d", h->fd, condition);
 
-       if (condition & G_IO_ERR)
-               _E("udev_monitor_set_receive_buffer_size overflow.");
-
-       if (!(condition & G_IO_IN)) {
-               _D("udev have a bad behavior.");
-               return TRUE;
+       if (!(condition & G_IO_IN) && (condition & (G_IO_ERR | G_IO_HUP))) {
+               remove_fd_read_handler((fd_handler_h *)&h);
+               return FALSE;
        }
 
        ret = true;
@@ -116,7 +115,7 @@ int add_fd_read_handler(int fd,
                return -ENOMEM;
        }
 
-       id = g_io_add_watch(ch, G_IO_IN | G_IO_ERR,
+       id = g_io_add_watch(ch, G_IO_IN | G_IO_ERR | G_IO_HUP,
                        channel_changed, h);
        if (id == 0) {
                _E("Failed to add watch for GIOChannel.");