remove the need for an explicit rpc context for the highlevel function mount_getexports()
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Sun, 19 Jun 2011 13:20:35 +0000 (23:20 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Sun, 19 Jun 2011 13:20:35 +0000 (23:20 +1000)
examples/nfsclient-sync.c
include/libnfs.h
lib/libnfs-sync.c

index 6fc219e302549e82045c093ea102082647fb8d4c..93704431d2d8f5aa7383d26346ae7934385059f2 100644 (file)
@@ -62,19 +62,15 @@ int main(int argc _U_, char *argv[] _U_)
        off_t offset;
        struct statvfs svfs;
        exports export, tmp;
-       struct rpc_context *mount_context;
 
        printf("exports on server %s\n", SERVER);
-       mount_context = rpc_init_context();
-       export = mount_getexports(mount_context, SERVER);
+       export = mount_getexports(SERVER);
        tmp = export;
        while (tmp != NULL) {
              printf("Export: %s\n", tmp->ex_dir);
              tmp = tmp->ex_next;
        }
        mount_free_export_list(export);
-       rpc_destroy_context(mount_context);
-
 
 
        nfs = nfs_init_context();
index de46b5ec3fd088cedaa5223b326c212a4da27073..e77e1d6974acbf4c55f10c183c591a3e68fcfea3 100644 (file)
@@ -945,7 +945,7 @@ int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb c
  * 
  * returned data must be freed by calling mount_free_export_list(exportnode);
  */
-struct exportnode *mount_getexports(struct rpc_context *rpc, const char *server);
+struct exportnode *mount_getexports(const char *server);
 
 void mount_free_export_list(struct exportnode *exports);
 
index cef644475f296f2c55719e64a8fcbbe91332dbb4..3b10e0a28a1843f5c420def19af95a30e53e56e2 100644 (file)
@@ -1093,19 +1093,23 @@ void mount_getexports_cb(struct rpc_context *mount_context _U_, int status, void
        }
 }
 
-struct exportnode *mount_getexports(struct rpc_context *rpc, const char *server)
+struct exportnode *mount_getexports(const char *server)
 {
        struct sync_cb_data cb_data;
+       struct rpc_context *rpc;
+
 
        cb_data.is_finished = 0;
        cb_data.return_data = NULL;
 
+       rpc = rpc_init_context();
        if (mount_getexports_async(rpc, server, mount_getexports_cb, &cb_data) != 0) {
-               rpc_set_error(rpc, "mount_getexports_async failed");
+               rpc_destroy_context(rpc);
                return NULL;
        }
 
        wait_for_reply(rpc, &cb_data);
+       rpc_destroy_context(rpc);
 
        return cb_data.return_data;
 }