- return toResult(client->request(type, toString(userName), toString(password), fromSTGPairs(pairs)));
+ if (!client->connected())
+ {
+ if (!STG_CLIENT::reconnect())
+ return emptyResult();
+ client = STG_CLIENT::get();
+ }
+ response.done = false;
+ client->request(type, toString(userName), toString(password), fromSTGPairs(pairs));
+ pthread_mutex_lock(&response.mutex);
+ while (!response.done)
+ pthread_cond_wait(&response.cond, &response.mutex);
+ pthread_mutex_unlock(&response.mutex);
+ if (!response.status)
+ return emptyResult();
+ return toResult(response.result);