16 : maxCli(maxClients), maxSess(maxSessions) {
22 nameMap =
new map<string, int>();
33 pthread_mutex_destroy(&
mapLock);
38 if (pthread_mutex_init(&
mapLock,NULL) != 0)
return false;
39 for (
int clx = 1; clx <=
maxCli; clx++) {
41 if (pthread_cond_init(&
cvec[clx].busyCond,NULL) != 0)
78 map<string, int>::iterator p =
nameMap->find(cname);
81 while (
cvec[clx].busyBit) {
85 pthread_cond_signal(&
cvec[clx].busyCond);
101 pthread_cond_signal(&
cvec[clx].busyCond);
115 if (sess == 0) {
unlockMap();
return 0; }
117 while (
cvec[clx].busyBit) {
121 pthread_cond_signal(&
cvec[clx].busyCond);
139 while (
cvec[clx].busyBit) {
143 pthread_cond_signal(&
cvec[clx].busyCond);
161 int nuClx =
clients->nextIn(clx);
164 pthread_cond_signal(&
cvec[clx].busyCond);
168 while (
cvec[nuClx].busyBit) {
173 pthread_cond_signal(&
cvec[clx].busyCond);
174 pthread_cond_signal(&
cvec[nuClx].busyCond);
181 pthread_cond_signal(&
cvec[clx].busyCond);
201 privileges priv,
int clx) {
203 map<string,int>::iterator p =
nameMap->find(cname);
206 if (
clients->isIn(clx)) clx = 0;
211 nameMap->insert(pair<string,int>(cname,clx));
221 maxClx = max(clx,maxClx);
233 while (
cvec[clx].firstSess != 0)
237 pthread_cond_signal(&
cvec[clx].busyCond);
253 if (sess == 0) {
unlockMap();
return 0; }
257 if (
cvec[clx].firstSess == 0) {
276 if (
cvec[clx].firstSess == sess) {
301 string cname, pwd, privString, realName, email;
304 if (!in.good())
return false;
312 !totalRates.
read(in)) {
317 maxClx = max(clx, maxClx);
324 if (privString ==
"limited") priv = LIMITED;
325 else if (privString ==
"standard") priv = STANDARD;
326 else if (privString ==
"admin") priv = ADMIN;
327 else if (privString ==
"root") priv = ROOT;
328 else priv = NUL_PRIV;
330 if (
addClient(cname, pwd, priv,clx) == 0)
return false;
395 cout <<
"read " << i <<
" client records, producing "
396 <<
clients->getNumIn() <<
"table entries\n";
413 case LIMITED: s +=
"limited";
break;
414 case STANDARD: s +=
"standard";
break;
415 case ADMIN: s +=
"admin";
break;
416 case ROOT: s +=
"root";
break;