mirror of
https://github.com/haiwen/libsearpc.git
synced 2025-07-31 04:49:43 +00:00
Fix bugs in async rpc
This commit is contained in:
parent
e4d932f0c0
commit
60ec606453
@ -28,7 +28,7 @@ typedef struct {
|
||||
|
||||
/* rpc_priv is used by the rpc_client to store information related to
|
||||
* this rpc call. */
|
||||
static int transport_send(void *arg, const char *fcall_str,
|
||||
static int transport_send(void *arg, char *fcall_str,
|
||||
size_t fcall_len, void *rpc_priv)
|
||||
{
|
||||
TcpTransport *trans = arg;
|
||||
@ -49,6 +49,7 @@ static int transport_send(void *arg, const char *fcall_str,
|
||||
}
|
||||
|
||||
trans->rpc_priv = rpc_priv;
|
||||
g_free (fcall_str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ def gen_dfun_macro_list():
|
||||
async_dfun_template = r"""
|
||||
#define SEARPC_CLIENT_ASYNC_DEFUN_${RET_TYPE}__${ARG_TYPES}(funcname, gtype) \
|
||||
int \
|
||||
funcname (SearpcClient *client, ${args}, \
|
||||
funcname (SearpcClient *client, ${args} \
|
||||
AsyncCallback callback, void *user_data) \
|
||||
{ \
|
||||
char *fcall; \
|
||||
@ -358,7 +358,7 @@ def gen_async_dfun_macro(ret_type, arg_types):
|
||||
|
||||
args = ""
|
||||
for i, arg_type in enumerate(arg_types):
|
||||
args += type_table[arg_type][0] + " param" + str(i+1)
|
||||
args += type_table[arg_type][0] + " param" + str(i+1) + ", "
|
||||
|
||||
fcall_args = ""
|
||||
for i, arg_type in enumerate(arg_types):
|
||||
|
@ -74,7 +74,7 @@ searpc_client_generic_callback (char *retstr, size_t len,
|
||||
|
||||
int
|
||||
searpc_client_async_call (SearpcClient *client,
|
||||
const gchar *fcall_str,
|
||||
gchar *fcall_str,
|
||||
size_t fcall_len,
|
||||
AsyncCallback callback,
|
||||
const gchar *ret_type,
|
||||
|
@ -7,9 +7,13 @@
|
||||
typedef char *(*TransportCB)(void *arg, const gchar *fcall_str,
|
||||
size_t fcall_len, size_t *ret_len);
|
||||
|
||||
/* rpc_priv is used by the rpc_client to store information related to
|
||||
* this rpc call. */
|
||||
typedef int (*AsyncTransportSend)(void *arg, const gchar *fcall_str,
|
||||
/**
|
||||
* @rpc_priv is used by the rpc_client to store information related to
|
||||
* this rpc call.
|
||||
* @fcall_str is an allocated string, and the sender should free it
|
||||
* when not needed.
|
||||
*/
|
||||
typedef int (*AsyncTransportSend)(void *arg, gchar *fcall_str,
|
||||
size_t fcall_len, void *rpc_priv);
|
||||
|
||||
typedef void (*AsyncCallback) (void *result, void *user_data, GError *error);
|
||||
@ -42,13 +46,15 @@ char* searpc_client_transport_send (SearpcClient *client,
|
||||
* @cbdata: the data that will be given to the callback.
|
||||
*/
|
||||
int searpc_client_async_call (SearpcClient *client,
|
||||
const gchar *fcall_str,
|
||||
gchar *fcall_str,
|
||||
size_t fcall_len,
|
||||
AsyncCallback callback,
|
||||
const gchar *ret_type,
|
||||
int gtype,
|
||||
void *cbdata);
|
||||
|
||||
/* called by the transport layer, the rpc layer should be able to
|
||||
* modify the str, but not take ownership of it */
|
||||
int
|
||||
searpc_client_generic_callback (char *retstr, size_t len,
|
||||
void *vdata, const char *errstr);
|
||||
|
Loading…
Reference in New Issue
Block a user