]> git.meshlink.io Git - catta/commitdiff
If the client calls EntryGroup::Commit update the local state immediately and
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Aug 2006 21:02:46 +0000 (21:02 +0000)
committerLennart Poettering <lennart@poettering.net>
Thu, 24 Aug 2006 21:02:46 +0000 (21:02 +0000)
do not delay this until the server informed us about the state change
asynchronously. The reason for this change is that otherwise all functions that
access the entry group depend on the out-of-date state for their validity
checks, which is obviously a bad idea.

git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1269 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-client/entrygroup.c

index e43a44fb8ae42b61db5785ce7f084d0141187d58..ea9b6767cf531d95630bf4f80db999d898054219 100644 (file)
@@ -249,21 +249,31 @@ int avahi_entry_group_free(AvahiEntryGroup *group) {
 }
 
 int avahi_entry_group_commit(AvahiEntryGroup *group) {
+    int ret;
     assert(group);
     
     if (!group->path || !avahi_client_is_connected(group->client))
         return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
 
-    return entry_group_simple_method_call(group, "Commit");
+    if ((ret = entry_group_simple_method_call(group, "Commit")) < 0)
+        return ret;
+
+    avahi_entry_group_set_state(group, AVAHI_ENTRY_GROUP_REGISTERING);
+    return 0;
 }
 
 int avahi_entry_group_reset(AvahiEntryGroup *group) {
+    int ret;
     assert(group);
     
     if (!group->path || !avahi_client_is_connected(group->client))
         return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE);
 
-    return entry_group_simple_method_call(group, "Reset");
+    if ((ret = entry_group_simple_method_call(group, "Reset")) < 0)
+        return ret;
+
+    avahi_entry_group_set_state(group, AVAHI_ENTRY_GROUP_UNCOMMITED);
+    return 0;
 }
 
 int avahi_entry_group_get_state (AvahiEntryGroup *group) {