Tcl package Thread source code

Check-in [2321e9578f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Do not use a static array to store handlers names. This solves the problem of an invalid empty initialization list when no handlers are available.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | thread-2-8-0
Files: files | file ages | folders
SHA1: 2321e9578fce6e93f021f2b99cf86e58633e0601
User & Date: gahr 2016-07-15 08:56:59
Context
2016-11-14
17:52
[63c86edf71] Check arguments in tpool::post check-in: aff57ffaaa user: gahr tags: trunk
2016-07-15
08:56
Do not use a static array to store handlers names. This solves the problem of an invalid empty initialization list when no handlers are available. check-in: 2321e9578f user: gahr tags: trunk, thread-2-8-0
2016-07-05
11:31
Re-generate "configure" with latest TEA. Many end-of-line spacings removed. check-in: 7de0ea7e11 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/threadSvCmd.c.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "threadSvListCmd.h"    /* Shared variants of list commands */
#include "threadSvKeylistCmd.h" /* Shared variants of list commands */
#include "psGdbm.h"             /* The gdbm persistent store implementation */
#include "psLmdb.h"             /* The lmdb persistent store implementation */

#define SV_FINALIZE

/*
 * Names of registered persistent storage handlers.
 */
static const char * handlers[] = {
#ifdef HAVE_GDBM
    "gdbm",
#endif
#ifdef HAVE_LMDB
    "lmdb",
#endif
};

/*
 * Number of buckets to spread shared arrays into. Each bucket is
 * associated with one mutex so locking a bucket locks all arrays
 * in that bucket as well. The number of buckets should be a prime.
 */

#define NUMBUCKETS 31







<
<
<
<
<
<
<
<
<
<
<
<







19
20
21
22
23
24
25












26
27
28
29
30
31
32
#include "threadSvListCmd.h"    /* Shared variants of list commands */
#include "threadSvKeylistCmd.h" /* Shared variants of list commands */
#include "psGdbm.h"             /* The gdbm persistent store implementation */
#include "psLmdb.h"             /* The lmdb persistent store implementation */

#define SV_FINALIZE













/*
 * Number of buckets to spread shared arrays into. Each bucket is
 * associated with one mutex so locking a bucket locks all arrays
 * in that bucket as well. The number of buckets should be a prime.
 */

#define NUMBUCKETS 31
2099
2100
2101
2102
2103
2104
2105


2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118




2119
2120
2121
2122
2123
2124
2125
static int
SvHandlersObjCmd(
             ClientData arg,                     /* Not used. */
             Tcl_Interp *interp,                 /* Current interpreter. */
             int objc,                           /* Number of arguments. */
             Tcl_Obj *const objv[])              /* Argument objects. */
{


    /*
     * Syntax:
     *
     *     tsv::handlers
     */

    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, NULL);
        return TCL_ERROR;
    }

    Tcl_SetObjResult(interp, Tcl_NewStringObj(
                Tcl_Merge(sizeof(handlers)/sizeof(handlers[0]), handlers), -1));





    return TCL_OK;
}


/*
 *-----------------------------------------------------------------------------







>
>











|
|
>
>
>
>







2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
static int
SvHandlersObjCmd(
             ClientData arg,                     /* Not used. */
             Tcl_Interp *interp,                 /* Current interpreter. */
             int objc,                           /* Number of arguments. */
             Tcl_Obj *const objv[])              /* Argument objects. */
{
    PsStore *tmpPtr = NULL;

    /*
     * Syntax:
     *
     *     tsv::handlers
     */

    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, NULL);
        return TCL_ERROR;
    }

    Tcl_ResetResult(interp);
    Tcl_MutexLock(&svMutex);
    for (tmpPtr = psStore; tmpPtr; tmpPtr = tmpPtr->nextPtr) {
        Tcl_AppendElement(interp, tmpPtr->type);
    }
    Tcl_MutexUnlock(&svMutex);

    return TCL_OK;
}


/*
 *-----------------------------------------------------------------------------