Create a generic RPC NULL function
This allows us to use the NULL function for any arbitrary program/version from rpc_connect_program() instead of the hardcoded support for mount v3 and nfs v3 Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>libnfs-4.0.0-vitalif
parent
468424c475
commit
6f27daf6d4
|
@ -1699,6 +1699,23 @@ EXTERN int rpc_nsm1_simucrash_async(struct rpc_context *rpc, rpc_cb cb, void *pr
|
|||
struct NSM1_NOTIFYargs;
|
||||
EXTERN int rpc_nsm1_notify_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_NOTIFYargs *args, void *private_data);
|
||||
|
||||
/*
|
||||
* Call <generic>/NULL
|
||||
* Function returns
|
||||
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
|
||||
* <0 : An error occured when trying to set up the connection. The callback will not be invoked.
|
||||
*
|
||||
* When the callback is invoked, status indicates the result:
|
||||
* RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
|
||||
* data is NULL.
|
||||
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
|
||||
* data is the error string.
|
||||
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
|
||||
* data is NULL.
|
||||
*/
|
||||
EXTERN int
|
||||
rpc_null_async(struct rpc_context *rpc, int program, int version, rpc_cb cb, void *private_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -212,6 +212,7 @@ rpc_nsm1_unmon_async
|
|||
rpc_nsm1_unmonall_async
|
||||
rpc_nsm1_simucrash_async
|
||||
rpc_nsm1_notify_async
|
||||
rpc_null_async
|
||||
rpc_rquota1_null_async
|
||||
rpc_rquota1_getquota_async
|
||||
rpc_rquota1_getactivequota_async
|
||||
|
|
38
lib/libnfs.c
38
lib/libnfs.c
|
@ -628,27 +628,12 @@ static void rpc_connect_program_4_cb(struct rpc_context *rpc, int status, void *
|
|||
return;
|
||||
}
|
||||
|
||||
switch (data->program) {
|
||||
case MOUNT_PROGRAM:
|
||||
if (rpc_mount3_null_async(rpc, rpc_connect_program_5_cb,
|
||||
data) != 0) {
|
||||
if (rpc_null_async(rpc, data->program, data->version,
|
||||
rpc_connect_program_5_cb, data) != 0) {
|
||||
data->cb(rpc, status, command_data, data->private_data);
|
||||
free_rpc_cb_data(data);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
case NFS_PROGRAM:
|
||||
if (rpc_nfs3_null_async(rpc, rpc_connect_program_5_cb,
|
||||
data) != 0) {
|
||||
data->cb(rpc, status, command_data, data->private_data);
|
||||
free_rpc_cb_data(data);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
data->cb(rpc, status, NULL, data->private_data);
|
||||
free_rpc_cb_data(data);
|
||||
}
|
||||
|
||||
static void rpc_connect_program_3_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data)
|
||||
|
@ -5690,3 +5675,22 @@ int nfs_get_timeout(struct nfs_context *nfs)
|
|||
{
|
||||
return rpc_get_timeout(nfs->rpc);
|
||||
}
|
||||
|
||||
int rpc_null_async(struct rpc_context *rpc, int program, int version, rpc_cb cb, void *private_data)
|
||||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, program, version, 0, cb, private_data, (zdrproc_t)zdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NULL call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rpc_queue_pdu(rpc, pdu) != 0) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NULL call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue