X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgenerator.ml;h=cf5db8764c078aa4f93e0fbc8ffe90a58fa79933;hb=749708a7ec8930c34605ec58c18fefe0ed8e7981;hp=6df04a598629f997df82a1f7da651c5994724ab1;hpb=42a8baf3c9abc6f742671f37e9e24b607e5f9857;p=libguestfs.git diff --git a/src/generator.ml b/src/generator.ml index 6df04a5..cf5db87 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -1253,7 +1253,6 @@ Reread the partition table on C. This uses the L command."); -(* ("upload", (RErr, [FileIn "filename"; String "remotefilename"]), 66, [], [], "upload a file from the local machine", @@ -1275,7 +1274,6 @@ on the local machine. C can also be a named pipe. See also C, C."); -*) ] @@ -2146,8 +2144,7 @@ check_state (guestfs_h *g, const char *caller) pr " /* This flag is set by the callbacks, so we know we've done\n"; pr " * the callbacks as expected, and in the right sequence.\n"; pr " * 0 = not called, 1 = send called,\n"; - pr " * 2.. = send_file called,\n"; - pr " * 1000 = reply called.\n"; + pr " * 1001 = reply called.\n"; pr " */\n"; pr " int cb_sequence;\n"; pr " struct guestfs_message_header hdr;\n"; @@ -2167,24 +2164,14 @@ check_state (guestfs_h *g, const char *caller) pr "};\n"; pr "\n"; - (* Generate the send callback function. *) - pr "static void %s_send_cb (guestfs_h *g, void *data)\n" shortname; - pr "{\n"; - pr " guestfs_main_loop *ml = guestfs_get_main_loop (g);\n"; - pr " struct %s_ctx *ctx = (struct %s_ctx *) data;\n" shortname shortname; - pr "\n"; - pr " guestfs__switch_to_receiving (g);\n"; - pr " ctx->cb_sequence = 1;\n"; - pr " ml->main_loop_quit (ml, g);\n"; - pr "}\n"; - pr "\n"; - (* Generate the reply callback function. *) pr "static void %s_reply_cb (guestfs_h *g, void *data, XDR *xdr)\n" shortname; pr "{\n"; pr " guestfs_main_loop *ml = guestfs_get_main_loop (g);\n"; pr " struct %s_ctx *ctx = (struct %s_ctx *) data;\n" shortname shortname; pr "\n"; + pr " ml->main_loop_quit (ml, g);\n"; + pr "\n"; pr " if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {\n"; pr " error (g, \"%%s: failed to parse reply header\", \"%s\");\n" name; pr " return;\n"; @@ -2215,8 +2202,7 @@ check_state (guestfs_h *g, const char *caller) ); pr " done:\n"; - pr " ctx->cb_sequence = 1000;\n"; - pr " ml->main_loop_quit (ml, g);\n"; + pr " ctx->cb_sequence = 1001;\n"; pr "}\n\n"; (* Generate the action stub. *) @@ -2250,10 +2236,10 @@ check_state (guestfs_h *g, const char *caller) pr " memset (&ctx, 0, sizeof ctx);\n"; pr "\n"; - (* Dispatch the main header and arguments. *) + (* Send the main header and arguments. *) (match snd style with | [] -> - pr " serial = guestfs__send (g, GUESTFS_PROC_%s, NULL, NULL);\n" + pr " serial = guestfs__send_sync (g, GUESTFS_PROC_%s, NULL, NULL);\n" (String.uppercase shortname) | args -> List.iter ( @@ -2271,7 +2257,7 @@ check_state (guestfs_h *g, const char *caller) pr " args.%s = %s;\n" n n | FileIn _ | FileOut _ -> () ) args; - pr " serial = guestfs__send (g, GUESTFS_PROC_%s,\n" + pr " serial = guestfs__send_sync (g, GUESTFS_PROC_%s,\n" (String.uppercase shortname); pr " (xdrproc_t) xdr_%s_args, (char *) &args);\n" name; @@ -2280,33 +2266,23 @@ check_state (guestfs_h *g, const char *caller) pr " return %s;\n" error_code; pr "\n"; - (* Send the request. *) - pr " ctx.cb_sequence = 0;\n"; - pr " guestfs_set_send_callback (g, %s_send_cb, &ctx);\n" shortname; - pr " (void) ml->main_loop_run (ml, g);\n"; - pr " guestfs_set_send_callback (g, NULL, NULL);\n"; - pr " if (ctx.cb_sequence != 1) {\n"; - pr " error (g, \"%%s send failed, see earlier error messages\", \"%s\");\n" name; - pr " return %s;\n" error_code; - pr " }\n"; - pr "\n"; - - (* Send any additional files requested. *) + (* Send any additional files (FileIn) requested. *) List.iter ( function | FileIn n -> - pr " if (send_file (g, %s) == -1)\n" n; + pr " if (guestfs__send_file_sync (g, %s) == -1)\n" n; pr " return %s;\n" error_code; pr "\n"; | _ -> () ) (snd style); (* Wait for the reply from the remote end. *) + pr " guestfs__switch_to_receiving (g);\n"; pr " ctx.cb_sequence = 0;\n"; pr " guestfs_set_reply_callback (g, %s_reply_cb, &ctx);\n" shortname; pr " (void) ml->main_loop_run (ml, g);\n"; pr " guestfs_set_reply_callback (g, NULL, NULL);\n"; - pr " if (ctx.cb_sequence != 1000) {\n"; + pr " if (ctx.cb_sequence != 1001) {\n"; pr " error (g, \"%%s reply failed, see earlier error messages\", \"%s\");\n" name; pr " return %s;\n" error_code; pr " }\n"; @@ -2327,7 +2303,7 @@ check_state (guestfs_h *g, const char *caller) List.iter ( function | FileOut n -> - pr " if (receive_file (g, %s) == -1)\n" n; + pr " if (guestfs__receive_file_sync (g, %s) == -1)\n" n; pr " return %s;\n" error_code; pr "\n"; | _ -> ()