[lib-fix] Fixed return value of kdbus_write_msg
authorSangyoon Jang <s89.jang@samsung.com>
Mon, 13 Jan 2014 08:37:02 +0000 (17:37 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Mon, 13 Jan 2014 09:51:46 +0000 (18:51 +0900)
Change-Id: Ia3a45a6a79b40789293603982cee6e3023a2f450

dbus/dbus-transport-kdbus.c

index 8f20119..67c85f3 100644 (file)
@@ -497,32 +497,26 @@ static int kdbus_write_msg(DBusTransportKdbus *transport, DBusMessage *message,
         goto again;
       else if(errno == ENXIO) //no such id on the bus
         {
+          ret_size = 0;
           if(!reply_with_error(DBUS_ERROR_NAME_HAS_NO_OWNER, "Name \"%s\" does not exist", dbus_message_get_destination(message), message, transport->base.connection))
-            {
-              ret_size = -1;
               goto out;
-            }
 
         }
       else if((errno == ESRCH) || (errno = EADDRNOTAVAIL))  //when well known name is not available on the bus
         {
+          ret_size = 0;
           if(autostart)
             {
               if(!reply_with_error(DBUS_ERROR_SERVICE_UNKNOWN, "The name %s was not provided by any .service files", dbus_message_get_destination(message), message, transport->base.connection))
-                {
-                  ret_size = -1;
                   goto out;
-                }
             }
           else
             if(!reply_with_error(DBUS_ERROR_NAME_HAS_NO_OWNER, "Name \"%s\" does not exist", dbus_message_get_destination(message), message, transport->base.connection))
-              {
-                ret_size = -1;
                 goto out;
-              }
         }
+      else
+        ret_size = -1;
       _dbus_verbose("kdbus error sending message: err %d (%m)\n", errno);
-      ret_size = -1;
     }
   out:
   if(msg)
@@ -1400,6 +1394,12 @@ do_writing (DBusTransport *transport)
               goto out;
             }
         }
+      else if (bytes_written == 0)
+        {
+           _dbus_verbose ("Destination is not available\n");
+           _dbus_connection_message_sent_unlocked (transport->connection,
+                   message);
+        }
       else
         {
           _dbus_verbose (" wrote %d bytes of %d\n", bytes_written,