Browse code

core: rpc capabilities and delayed reply api

- added a new rpc function for interrogating the current rpc
transport capabilities (for now the only extra capability is
RPC_DELAYED_REPLY).
- added a new special delayed reply rpc context and rpc functions hooks for
creating and closing it.

Andrei Pelinescu-Onciul authored on 30/07/2009 13:40:42
Showing 1 changed files
... ...
@@ -37,7 +37,13 @@ enum rpc_flags {
37 37
 	RET_ARRAY = (1 << 0),
38 38
 	RET_VALUE = (1 << 1)
39 39
 };
40
-	
40
+
41
+typedef enum rpc_capabilities {
42
+	RPC_DELAYED_REPLY = (1 <<0)  /* delayed reply support */
43
+} rpc_capabilities_t;
44
+
45
+struct rpc_delayed_ctx;
46
+
41 47
 
42 48
 /* Send the result to the caller */
43 49
 typedef int (*rpc_send_f)(void* ctx);                                      /* Send the reply to the client */
... ...
@@ -49,6 +55,13 @@ typedef int (*rpc_struct_add_f)(void* ctx, char* fmt, ...);                /* Cr
49 49
 typedef int (*rpc_struct_scan_f)(void* ctx, char* fmt, ...);               /* Scan attributes of a structure */
50 50
 typedef int (*rpc_struct_printf_f)(void* ctx, char* name, char* fmt, ...); /* Struct version of rpc_printf */
51 51
 
52
+/* returns the supported capabilities */
53
+typedef rpc_capabilities_t (*rpc_capabilities_f)(void* ctx);
54
+/* create a special "context" for delayed replies */
55
+typedef struct rpc_delayed_ctx* (*rpc_delayed_ctx_new_f)(void* ctx);
56
+/* close the special "context" for delayed replies */
57
+typedef void (*rpc_delayed_ctx_close_f)(struct rpc_delayed_ctx* dctx);
58
+
52 59
 /*
53 60
  * RPC context, this is what RPC functions get as a parameter and use
54 61
  * it to obtain the value of the parameters of the call and reference
... ...
@@ -63,9 +76,19 @@ typedef struct rpc {
63 63
 	rpc_struct_add_f struct_add;
64 64
 	rpc_struct_scan_f struct_scan;
65 65
 	rpc_struct_printf_f struct_printf;
66
+	rpc_capabilities_f capabilities;
67
+	rpc_delayed_ctx_new_f delayed_ctx_new;
68
+	rpc_delayed_ctx_close_f delayed_ctx_close;
66 69
 } rpc_t;
67 70
 
68 71
 
72
+typedef struct rpc_delayed_ctx{
73
+	rpc_t rpc;
74
+	void* reply_ctx;
75
+	/* more private data might follow */
76
+} rpc_delayed_ctx_t;
77
+
78
+
69 79
 /*
70 80
  * RPC Function Prototype
71 81
  */