Check-in [f277407cbc]
Overview
Comment:Converted global variables to not be part of a struct
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tcl-ops
Files: files | file ages | folders
SHA1:f277407cbc75e377b0f8e19b48d981f1a0f12e42
User & Date: rkeene on 2014-11-07 07:20:36
Other Links: manifest | tags
Context
2014-11-07
08:48
Added basic "getchildren" implementation in Tcl check-in: ee13ee5aa4 user: rkeene tags: tcl-ops
07:20
Converted global variables to not be part of a struct check-in: f277407cbc user: rkeene tags: tcl-ops
07:17
Updated Makefile check-in: a6cb122222 user: rkeene tags: tcl-ops
Changes

Modified appfsd.c from [2188b35dbc] to [a9240a597b].

    34     34   
    35     35   /*
    36     36    * Thread Specific Data (TSD) for Tcl Interpreter for the current thread
    37     37    */
    38     38   static pthread_key_t interpKey;
    39     39   
    40     40   /*
    41         - * Data for a given thread (most likely these will become just globable variables soon.)
           41  + * Global variables, needed for all threads but only initialized before any
           42  + * FUSE threads are created
    42     43    */
    43         -struct appfs_thread_data {
    44         -	const char *cachedir;
    45         -	time_t boottime;
    46         -	struct {
    47         -		int writable;
    48         -	} options;
    49         -};
    50         -
    51         -/* The global thread data (likely to go away) */
    52         -struct appfs_thread_data globalThread;
           44  +const char *appfs_cachedir;
           45  +time_t appfs_boottime;
    53     46   
    54     47   /*
    55     48    * AppFS Path Type:  Describes the type of path a given file is
    56     49    */
    57     50   typedef enum {
    58     51   	APPFS_PATHTYPE_INVALID,
    59     52   	APPFS_PATHTYPE_FILE,
................................................................................
    96     89   };
    97     90   
    98     91   /*
    99     92    * Create a new Tcl interpreter and completely initialize it
   100     93    */
   101     94   static Tcl_Interp *appfs_create_TclInterp(void) {
   102     95   	Tcl_Interp *interp;
   103         -	const char *cachedir = globalThread.cachedir;
   104     96   	int tcl_ret;
   105     97   
   106     98   	APPFS_DEBUG("Creating new Tcl interpreter for TID = 0x%llx", (unsigned long long) pthread_self());
   107     99   
   108    100   	interp = Tcl_CreateInterp();
   109    101   	if (interp == NULL) {
   110    102   		fprintf(stderr, "Unable to create Tcl Interpreter.  Aborting.\n");
................................................................................
   158    150   
   159    151   		return(NULL);
   160    152   	}
   161    153   
   162    154   	/*
   163    155   	 * Set global variables from C to Tcl
   164    156   	 */
   165         -	if (Tcl_SetVar(interp, "::appfs::cachedir", cachedir, TCL_GLOBAL_ONLY) == NULL) {
          157  +	if (Tcl_SetVar(interp, "::appfs::cachedir", appfs_cachedir, TCL_GLOBAL_ONLY) == NULL) {
   166    158   		fprintf(stderr, "Unable to set cache directory.  This should never fail.\n");
   167    159   
   168    160   		Tcl_DeleteInterp(interp);
   169    161   
   170    162   		return(NULL);
   171    163   	}
   172    164   
................................................................................
   531    523   		case APPFS_PATHTYPE_INVALID:
   532    524   			res = -EIO;
   533    525   
   534    526   			break;
   535    527   	}
   536    528   
   537    529   	if (pathinfo.packaged) {
   538         -		if (globalThread.options.writable) {
          530  +		if (0) {
   539    531   			stbuf->st_mode |= 0222;
   540    532   		}
   541    533   	}
   542    534   
   543    535   	return res;
   544    536   }
   545    537   
................................................................................
   732    724    */
   733    725   static int appfs_fuse_opt_cb(void *data, const char *arg, int key, struct fuse_args *outargs) {
   734    726   	static seen_cachedir = 0;
   735    727   
   736    728   	if (key == FUSE_OPT_KEY_NONOPT && seen_cachedir == 0) {
   737    729   		seen_cachedir = 1;
   738    730   
   739         -		globalThread.cachedir = strdup(arg);
          731  +		appfs_cachedir = strdup(arg);
   740    732   
   741    733   		return(0);
   742    734   	}
   743    735   
   744    736   	return(1);
   745    737   }
   746    738   
................................................................................
   759    751   	}
   760    752   	argc--;
   761    753   	argv++;
   762    754   
   763    755   	/*
   764    756   	 * Set global variables, these should be configuration options.
   765    757   	 */
   766         -	globalThread.cachedir = APPFS_CACHEDIR;
   767         -	globalThread.options.writable = 1;
          758  +	appfs_cachedir = APPFS_CACHEDIR;
   768    759   
   769    760   	/*
   770    761   	 * Set global variable for "boot time" to set a time on directories
   771    762   	 * that we fake.
   772    763   	 */
   773         -	globalThread.boottime = time(NULL);
          764  +	appfs_boottime = time(NULL);
   774    765   
   775    766   	/*
   776    767   	 * Register "sha1" and "appfsd" package with libtcl so that any new
   777    768   	 * interpreters created (which are done dynamically by FUSE) can have
   778    769   	 * the appropriate configuration done automatically.
   779    770   	 */
   780    771   	Tcl_StaticPackage(NULL, "sha1", Sha1_Init, NULL);
................................................................................
   795    786   	/*
   796    787   	 * Manually specify cache directory, without FUSE callback
   797    788   	 * This option only works when not using FUSE, since we
   798    789   	 * do not process it with FUSEs option processing.
   799    790   	 */
   800    791   	if (argc >= 2) {
   801    792   		if (strcmp(argv[0], "--cachedir") == 0) {
   802         -			globalThread.cachedir = strdup(argv[1]);
          793  +			appfs_cachedir = strdup(argv[1]);
   803    794   
   804    795   			argc -= 2;
   805    796   			argv += 2;
   806    797   		}
   807    798   	}
   808    799   
   809    800   	/*