mirror of
https://github.com/haiwen/libsearpc.git
synced 2025-08-01 21:07:44 +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
|
/* rpc_priv is used by the rpc_client to store information related to
|
||||||
* this rpc call. */
|
* 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)
|
size_t fcall_len, void *rpc_priv)
|
||||||
{
|
{
|
||||||
TcpTransport *trans = arg;
|
TcpTransport *trans = arg;
|
||||||
@ -49,6 +49,7 @@ static int transport_send(void *arg, const char *fcall_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
trans->rpc_priv = rpc_priv;
|
trans->rpc_priv = rpc_priv;
|
||||||
|
g_free (fcall_str);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ def gen_dfun_macro_list():
|
|||||||
async_dfun_template = r"""
|
async_dfun_template = r"""
|
||||||
#define SEARPC_CLIENT_ASYNC_DEFUN_${RET_TYPE}__${ARG_TYPES}(funcname, gtype) \
|
#define SEARPC_CLIENT_ASYNC_DEFUN_${RET_TYPE}__${ARG_TYPES}(funcname, gtype) \
|
||||||
int \
|
int \
|
||||||
funcname (SearpcClient *client, ${args}, \
|
funcname (SearpcClient *client, ${args} \
|
||||||
AsyncCallback callback, void *user_data) \
|
AsyncCallback callback, void *user_data) \
|
||||||
{ \
|
{ \
|
||||||
char *fcall; \
|
char *fcall; \
|
||||||
@ -358,7 +358,7 @@ def gen_async_dfun_macro(ret_type, arg_types):
|
|||||||
|
|
||||||
args = ""
|
args = ""
|
||||||
for i, arg_type in enumerate(arg_types):
|
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 = ""
|
fcall_args = ""
|
||||||
for i, arg_type in enumerate(arg_types):
|
for i, arg_type in enumerate(arg_types):
|
||||||
|
@ -74,7 +74,7 @@ searpc_client_generic_callback (char *retstr, size_t len,
|
|||||||
|
|
||||||
int
|
int
|
||||||
searpc_client_async_call (SearpcClient *client,
|
searpc_client_async_call (SearpcClient *client,
|
||||||
const gchar *fcall_str,
|
gchar *fcall_str,
|
||||||
size_t fcall_len,
|
size_t fcall_len,
|
||||||
AsyncCallback callback,
|
AsyncCallback callback,
|
||||||
const gchar *ret_type,
|
const gchar *ret_type,
|
||||||
|
@ -7,9 +7,13 @@
|
|||||||
typedef char *(*TransportCB)(void *arg, const gchar *fcall_str,
|
typedef char *(*TransportCB)(void *arg, const gchar *fcall_str,
|
||||||
size_t fcall_len, size_t *ret_len);
|
size_t fcall_len, size_t *ret_len);
|
||||||
|
|
||||||
/* rpc_priv is used by the rpc_client to store information related to
|
/**
|
||||||
* this rpc call. */
|
* @rpc_priv is used by the rpc_client to store information related to
|
||||||
typedef int (*AsyncTransportSend)(void *arg, const gchar *fcall_str,
|
* 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);
|
size_t fcall_len, void *rpc_priv);
|
||||||
|
|
||||||
typedef void (*AsyncCallback) (void *result, void *user_data, GError *error);
|
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.
|
* @cbdata: the data that will be given to the callback.
|
||||||
*/
|
*/
|
||||||
int searpc_client_async_call (SearpcClient *client,
|
int searpc_client_async_call (SearpcClient *client,
|
||||||
const gchar *fcall_str,
|
gchar *fcall_str,
|
||||||
size_t fcall_len,
|
size_t fcall_len,
|
||||||
AsyncCallback callback,
|
AsyncCallback callback,
|
||||||
const gchar *ret_type,
|
const gchar *ret_type,
|
||||||
int gtype,
|
int gtype,
|
||||||
void *cbdata);
|
void *cbdata);
|
||||||
|
|
||||||
|
/* called by the transport layer, the rpc layer should be able to
|
||||||
|
* modify the str, but not take ownership of it */
|
||||||
int
|
int
|
||||||
searpc_client_generic_callback (char *retstr, size_t len,
|
searpc_client_generic_callback (char *retstr, size_t len,
|
||||||
void *vdata, const char *errstr);
|
void *vdata, const char *errstr);
|
||||||
|
Loading…
Reference in New Issue
Block a user