| 1124 | pthread_mutex_t parallel_load_mtx = PTHREAD_MUTEX_INITIALIZER; |
| 1125 | |
| 1126 | static int _add_parallel_load(struct sqlclntstate *clnt) |
| 1127 | { |
| 1128 | static int alert_parallel_disabled = 0; |
| 1129 | struct thdpool *pool = get_sql_pool(clnt); |
| 1130 | int maxt = thdpool_get_maxthds(pool); |
| 1131 | int thr_slack = (gbl_dohsql_pool_thr_slack > 0) ? gbl_dohsql_pool_thr_slack : 1; |
| 1132 | |
| 1133 | Pthread_mutex_lock(¶llel_load_mtx); |
| 1134 | if ((maxt - thr_slack) <= parallel_load) { |
| 1135 | if (!alert_parallel_disabled) { |
| 1136 | logmsg(LOGMSG_INFO, |
| 1137 | "Sql engine full, switching to non-parallel mode\n"); |
| 1138 | alert_parallel_disabled = 1; |
| 1139 | } |
| 1140 | Pthread_mutex_unlock(¶llel_load_mtx); |
| 1141 | return SHARD_ERR_LOAD; |
| 1142 | } else { |
| 1143 | if (alert_parallel_disabled) { |
| 1144 | logmsg(LOGMSG_INFO, |
| 1145 | "Sql engine load cleared, re-activating parallel mode\n"); |
| 1146 | alert_parallel_disabled = 0; |
| 1147 | } |
| 1148 | } |
| 1149 | parallel_load++; |
| 1150 | Pthread_mutex_unlock(¶llel_load_mtx); |
| 1151 | |
| 1152 | return SHARD_NOERR; |
| 1153 | } |
| 1154 | |
| 1155 | static void _rem_parallel_load(void) |
| 1156 | { |
no test coverage detected