Check-in [d9f1a05711]
Overview
Comment:Updated to call Tcl_Preserve/Tcl_Release as appropriate
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d9f1a05711323fb72b3f01377bbb6d761c06bbf3
User & Date: rkeene on 2014-11-12 05:54:38
Other Links: manifest | tags
Context
2014-11-12
08:36
Corrected issue where package name was not considered when looking up package check-in: eb52173aaa user: rkeene tags: trunk
05:54
Updated to call Tcl_Preserve/Tcl_Release as appropriate check-in: d9f1a05711 user: rkeene tags: trunk
05:46
Fixed actual problem with interruptions (which was really unrelated) -- Tcl notifier thread is terminated on fork() called by fuse_main(), since we create a Tcl interpreter for testing before calling fuse_main() the notifier dies and is not restarted. We now terminate it before fork(). check-in: 0819a7a89c user: rkeene tags: trunk
Changes

Modified appfsd.c from [3ceaeb1976] to [e49bb6021f].

   658    658   		return(0);
   659    659   	}
   660    660   
   661    661   	interp = appfs_TclInterp();
   662    662   	if (interp == NULL) {
   663    663   		return(-EIO);
   664    664   	}
          665  +
          666  +	Tcl_Preserve(interp);
   665    667   
   666    668   	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::getattr", path);
   667    669   	if (tcl_ret != TCL_OK) {
   668    670   		APPFS_DEBUG("::appfs::getattr(%s) failed.", path);
   669    671   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
   670    672   
   671    673   		pathinfo->type = APPFS_PATHTYPE_DOES_NOT_EXIST;
   672    674   
   673    675   		appfs_get_path_info_cache_add(path, appfs_get_fsuid(), pathinfo);
          676  +
          677  +		Tcl_Release(interp);
   674    678   
   675    679   		return(-ENOENT);
   676    680   	}
   677    681   
   678    682   	if (attr_key_type == NULL) {
   679    683   		attr_key_type       = Tcl_NewStringObj("type", -1);
   680    684   		attr_key_perms      = Tcl_NewStringObj("perms", -1);
................................................................................
   687    691   
   688    692   	attrs_dict = Tcl_GetObjResult(interp);
   689    693   	tcl_ret = Tcl_DictObjGet(interp, attrs_dict, attr_key_type, &attr_value);
   690    694   	if (tcl_ret != TCL_OK) {
   691    695   		APPFS_DEBUG("[dict get \"type\"] failed");
   692    696   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
   693    697   
          698  +		Tcl_Release(interp);
          699  +
   694    700   		return(-EIO);
   695    701   	}
   696    702   
   697    703   	if (attr_value == NULL) {
          704  +		Tcl_Release(interp);
          705  +
   698    706   		return(-EIO);
   699    707   	}
   700    708   
   701    709   	pathinfo->packaged = 0;
   702    710   	pathinfo->inode = appfs_get_path_inode(path);
   703    711   
   704    712   	attr_value_str = Tcl_GetString(attr_value);
................................................................................
   757    765   		case 'F': /* pipe/fifo */
   758    766   			pathinfo->type = APPFS_PATHTYPE_FIFO;
   759    767   			break;
   760    768   		case 'S': /* UNIX domain socket */
   761    769   			pathinfo->type = APPFS_PATHTYPE_SOCKET;
   762    770   			break;
   763    771   		default:
          772  +			Tcl_Release(interp);
          773  +
   764    774   			return(-EIO);
   765    775   	}
   766    776   
   767    777   	Tcl_DictObjGet(interp, attrs_dict, attr_key_packaged, &attr_value);
   768    778   	if (attr_value != NULL) {
   769    779   		pathinfo->packaged = 1;
   770    780   	}
................................................................................
   774    784   		tcl_ret = Tcl_GetWideIntFromObj(NULL, attr_value, &attr_value_wide);
   775    785   		if (tcl_ret == TCL_OK) {
   776    786   			pathinfo->time = attr_value_wide;
   777    787   		}
   778    788   	} else {
   779    789   		pathinfo->time = 0;
   780    790   	}
          791  +
          792  +	Tcl_Release(interp);
   781    793   
   782    794   	appfs_get_path_info_cache_add(path, appfs_get_fsuid(), pathinfo);
   783    795   
   784    796   	return(0);
   785    797   }
   786    798   
   787    799   static char *appfs_prepare_to_create(const char *path) {
................................................................................
   791    803   
   792    804   	appfs_get_path_info_cache_flush(appfs_get_fsuid(), -1);
   793    805   
   794    806   	interp = appfs_TclInterp();
   795    807   	if (interp == NULL) {
   796    808   		return(NULL);
   797    809   	}
          810  +
          811  +	Tcl_Preserve(interp);
   798    812   
   799    813   	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::prepare_to_create", path);
   800    814   	if (tcl_ret != TCL_OK) {
   801    815   		APPFS_DEBUG("::appfs::prepare_to_create(%s) failed.", path);
   802    816   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
   803    817   
          818  +		Tcl_Release(interp);
          819  +
   804    820   		return(NULL);
   805    821   	}
   806    822   
   807    823   	real_path = Tcl_GetStringResult(interp);
          824  +
          825  +	Tcl_Release(interp);
          826  +
   808    827   	if (real_path == NULL) {
   809    828   		return(NULL);
   810    829   	}
   811    830   
   812    831   	return(strdup(real_path));
   813    832   }
   814    833   
................................................................................
   817    836   	const char *real_path;
   818    837   	int tcl_ret;
   819    838   
   820    839   	interp = appfs_TclInterp();
   821    840   	if (interp == NULL) {
   822    841   		return(NULL);
   823    842   	}
          843  +
          844  +	Tcl_Preserve(interp);
   824    845   
   825    846   	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::localpath", path);
   826    847   	if (tcl_ret != TCL_OK) {
   827    848   		APPFS_DEBUG("::appfs::localpath(%s) failed.", path);
   828    849   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
   829    850   
   830    851   		return(NULL);
   831    852   	}
   832    853   
   833    854   	real_path = Tcl_GetStringResult(interp);
          855  +
          856  +	Tcl_Release(interp);
          857  +
   834    858   	if (real_path == NULL) {
   835    859   		return(NULL);
   836    860   	}
   837    861   
   838    862   	return(strdup(real_path));
   839    863   }
   840    864   
................................................................................
   944    968   
   945    969   	APPFS_DEBUG("Enter (path = %s, ...)", path);
   946    970   
   947    971   	interp = appfs_TclInterp();
   948    972   	if (interp == NULL) {
   949    973   		return(0);
   950    974   	}
          975  +
          976  +	Tcl_Preserve(interp);
   951    977   
   952    978   	filler(buf, ".", NULL, 0);
   953    979   	filler(buf, "..", NULL, 0);
   954    980   
   955    981   	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::getchildren", path);
   956    982   	if (tcl_ret != TCL_OK) {
   957    983   		APPFS_DEBUG("::appfs::getchildren(%s) failed.", path);
   958    984   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
          985  +
          986  +		Tcl_Release(interp);
   959    987   
   960    988   		return(0);
   961    989   	}
   962    990   
   963    991   	tcl_ret = Tcl_ListObjGetElements(interp, Tcl_GetObjResult(interp), &children_count, &children);
   964    992   	if (tcl_ret != TCL_OK) {
   965    993   		APPFS_DEBUG("Parsing list of children on path %s failed.", path);
   966    994   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
   967    995   
          996  +		Tcl_Release(interp);
          997  +
   968    998   		return(0);
   969    999   	}
   970   1000   
   971   1001   	for (idx = 0; idx < children_count; idx++) {
   972   1002   		filler(buf, Tcl_GetString(children[idx]), NULL, 0);
   973   1003   	}
         1004  +
         1005  +	Tcl_Release(interp);
   974   1006   
   975   1007   	return(0);
   976   1008   }
   977   1009   
   978   1010   static int appfs_fuse_open(const char *path, struct fuse_file_info *fi) {
   979   1011   	Tcl_Interp *interp;
   980   1012   	struct appfs_pathinfo pathinfo;
................................................................................
  1016   1048   		return(-EISDIR);
  1017   1049   	}
  1018   1050   
  1019   1051   	interp = appfs_TclInterp();
  1020   1052   	if (interp == NULL) {
  1021   1053   		return(-EIO);
  1022   1054   	}
         1055  +
         1056  +	Tcl_Preserve(interp);
  1023   1057   
  1024   1058   	tcl_ret = appfs_Tcl_Eval(interp, 3, "::appfs::openpath", path, mode);
  1025   1059   	if (tcl_ret != TCL_OK) {
  1026   1060   		APPFS_DEBUG("::appfs::openpath(%s, %s) failed.", path, mode);
  1027   1061   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
  1028   1062   
         1063  +		Tcl_Release(interp);
         1064  +
  1029   1065   		return(-EIO);
  1030   1066   	}
  1031   1067   
  1032   1068   	real_path = Tcl_GetStringResult(interp);
         1069  +
         1070  +	Tcl_Release(interp);
         1071  +
  1033   1072   	if (real_path == NULL) {
  1034   1073   		return(-EIO);
  1035   1074   	}
  1036   1075   
  1037   1076   	APPFS_DEBUG("Translated request to open %s to opening %s (mode = \"%s\")", path, real_path, mode);
  1038   1077   
  1039   1078   	fh = open(real_path, fi->flags, 0600);
................................................................................
  1206   1245   	}
  1207   1246   
  1208   1247   	tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::unlinkpath", path);
  1209   1248   	if (tcl_ret != TCL_OK) {
  1210   1249   		APPFS_DEBUG("::appfs::unlinkpath(%s) failed.", path);
  1211   1250   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
  1212   1251   
         1252  +		Tcl_Release(interp);
         1253  +
  1213   1254   		return(-EIO);
  1214   1255   	}
         1256  +
         1257  +	Tcl_Release(interp);
  1215   1258   
  1216   1259   	return(0);
  1217   1260   }
  1218   1261   
  1219   1262   static int appfs_fuse_mkdir(const char *path, mode_t mode) {
  1220   1263   	char *real_path;
  1221   1264   	int mkdir_ret;
................................................................................
  1253   1296   
  1254   1297   	appfs_get_path_info_cache_rm(path, appfs_get_fsuid());
  1255   1298   
  1256   1299   	interp = appfs_TclInterp();
  1257   1300   	if (interp == NULL) {
  1258   1301   		return(-EIO);
  1259   1302   	}
         1303  +
         1304  +	Tcl_Preserve(interp);
  1260   1305   
  1261   1306   	tcl_ret = appfs_Tcl_Eval(interp, 3, "::appfs::openpath", path, "write");
  1262   1307   	if (tcl_ret != TCL_OK) {
  1263   1308   		APPFS_DEBUG("::appfs::openpath(%s, %s) failed.", path, "write");
  1264   1309   		APPFS_DEBUG("Tcl Error is: %s", Tcl_GetStringResult(interp));
  1265   1310   
         1311  +		Tcl_Release(interp);
         1312  +
  1266   1313   		return(-EIO);
  1267   1314   	}
  1268   1315   
  1269   1316   	real_path = Tcl_GetStringResult(interp);
         1317  +
         1318  +	Tcl_Release(interp);
         1319  +
  1270   1320   	if (real_path == NULL) {
  1271   1321   		return(-EIO);
  1272   1322   	}
  1273   1323   
  1274   1324   	appfs_simulate_user_fs_enter();
  1275   1325   
  1276   1326   	chmod_ret = chmod(real_path, mode);