| 122 | } |
| 123 | |
| 124 | static struct thdpool *create_sql_pool(const char *zName, int nThreads) |
| 125 | { |
| 126 | struct thdpool *pool = thdpool_create( |
| 127 | (zName != NULL) ? zName : SQL_POOL_LEGACY_NAME, |
| 128 | sizeof(struct sqlthdstate)); |
| 129 | |
| 130 | if (pool == NULL) return NULL; |
| 131 | |
| 132 | if (!gbl_exit_on_pthread_create_fail) |
| 133 | thdpool_unset_exit(pool); |
| 134 | |
| 135 | thdpool_set_stack_size(pool, SQL_POOL_STACK_SIZE); |
| 136 | thdpool_set_init_fn(pool, thdpool_sqlengine_start); |
| 137 | thdpool_set_delt_fn(pool, thdpool_sqlengine_end); |
| 138 | thdpool_set_dque_fn(pool, thdpool_sqlengine_dque); |
| 139 | thdpool_set_queued_callback(pool, clnt_queued_event); |
| 140 | |
| 141 | if (zName != NULL) { |
| 142 | /* TODO: *TUNING* Defaults for non-default pools. */ |
| 143 | thdpool_set_maxthds(pool, nThreads); |
| 144 | thdpool_set_maxqueueoverride(pool, SQL_POOL_NAMED_MAXQ_OVERRIDE); |
| 145 | } else { |
| 146 | thdpool_set_minthds(pool, SQL_POOL_DEFLT_MIN_THREADS); |
| 147 | thdpool_set_maxthds(pool, SQL_POOL_DEFLT_MAX_THREADS); |
| 148 | thdpool_set_linger(pool, SQL_POOL_LINGER_SECS); |
| 149 | thdpool_set_maxqueueoverride(pool, SQL_POOL_DEFLT_MAXQ_OVERRIDE); |
| 150 | thdpool_set_maxqueueagems(pool, SQL_POOL_MAXQ_AGE_MS); |
| 151 | thdpool_set_dump_on_full(pool, 1); |
| 152 | } |
| 153 | |
| 154 | return pool; |
| 155 | } |
| 156 | |
| 157 | /* |
| 158 | ** WARNING: The "try_add_sql_pool" function assumes the hash lock is already |
no test coverage detected