[vhffs-dev] [764] Well, rpc backend is _not_ thread safe (I am not kidding), so let' s rewrite some functions...

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 764
Author:   gradator
Date:     2007-08-14 21:49:18 +0000 (Tue, 14 Aug 2007)

Log Message:
-----------
Well, rpc backend is _not_ thread safe (I am not kidding), so let's rewrite some functions...

Modified Paths:
--------------
    trunk/vhffs-fs/vhffsfs.c


Modified: trunk/vhffs-fs/vhffsfs.c
===================================================================
--- trunk/vhffs-fs/vhffsfs.c	2007-08-14 14:23:10 UTC (rev 763)
+++ trunk/vhffs-fs/vhffsfs.c	2007-08-14 21:49:18 UTC (rev 764)
@@ -746,30 +746,37 @@
 int vhffsfs_checkquotagid_rpc(char *rpcserver, char *path, int gid)  {
 
 	CLIENT *clnt;
-	getquota_rslt *result=NULL;
-	union {
-		getquota_args arg;
-		ext_getquota_args ext_arg;
-	} args;
-	struct timeval timeout = { 10, 0 };
 
 	if(!rpcserver || !path || !gid)  return -EINVAL;
 
-	args.ext_arg.gqa_pathp = path;
-	args.ext_arg.gqa_id = gid;
-	args.ext_arg.gqa_type = GRPQUOTA;
-
 	if( (clnt = clnt_create(rpcserver, RQUOTAPROG, EXT_RQUOTAVERS, "udp"))  !=  NULL)  {
 
+		union {
+			getquota_args arg;
+			ext_getquota_args ext_arg;
+		} args;
+		struct timeval timeout = { 10, 0 };
+		ext_getquota_args *argp;
+		getquota_rslt clnt_res;
+		int res;
+
+		args.ext_arg.gqa_pathp = path;
+		args.ext_arg.gqa_id = gid;
+		args.ext_arg.gqa_type = GRPQUOTA;
+
 		clnt->cl_auth = authunix_create_default();
 		clnt_control(clnt, CLSET_TIMEOUT, (caddr_t)&timeout);
-		result = rquotaproc_getquota_2(&args.ext_arg, clnt);
+
+		//result = rquotaproc_getquota_2(&args.ext_arg, clnt);  // non-thread safe, rewritten below
+		argp = &args.ext_arg;
+		res = clnt_call(clnt, RQUOTAPROC_GETQUOTA, (xdrproc_t)xdr_ext_getquota_args, (caddr_t)argp, (xdrproc_t)xdr_getquota_rslt, (caddr_t)&clnt_res, timeout);
+
 		auth_destroy(clnt->cl_auth);
 		clnt_destroy(clnt);
 
-		if(result && result->status == Q_OK)  {
+		if(res == RPC_SUCCESS && clnt_res.status == Q_OK)  {
 
-			struct rquota *n = &result->getquota_rslt_u.gqr_rquota;
+			struct rquota *n = &clnt_res.getquota_rslt_u.gqr_rquota;
 			if(!n)  return -EIO;
 
 			/* printf("QUOTA -> GID: %d, HARDB: %d, SOFTB: %d, CURB: %d\n", gid, n->rq_bhardlimit, n->rq_bsoftlimit, n->rq_curblocks );
@@ -777,7 +784,7 @@
 			 */
 
 			if(n->rq_curblocks > n->rq_bhardlimit  ||  n->rq_curfiles > n->rq_fhardlimit)  return 1;
-
+	
 			/* printf("QUOTA -> OK !\n"); */
 		}
 		else return -EIO;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/