extract error messages from error queue
| 1140 | |
| 1141 | // extract error messages from error queue |
| 1142 | void buildErrors(string& errors, int errno_copy, int sslerrno) { |
| 1143 | unsigned long errorCode; |
| 1144 | char message[256]; |
| 1145 | |
| 1146 | errors.reserve(512); |
| 1147 | while ((errorCode = ERR_get_error()) != 0) { |
| 1148 | if (!errors.empty()) { |
| 1149 | errors += "; "; |
| 1150 | } |
| 1151 | const char* reason = ERR_reason_error_string(errorCode); |
| 1152 | if (reason == nullptr) { |
| 1153 | THRIFT_SNPRINTF(message, sizeof(message) - 1, "SSL error # %lu", errorCode); |
| 1154 | reason = message; |
| 1155 | } |
| 1156 | errors += reason; |
| 1157 | } |
| 1158 | if (errors.empty()) { |
| 1159 | if (errno_copy != 0) { |
| 1160 | errors += TOutput::strerror_s(errno_copy); |
| 1161 | } |
| 1162 | } |
| 1163 | if (errors.empty()) { |
| 1164 | errors = "error code: " + to_string(errno_copy); |
| 1165 | } |
| 1166 | if (sslerrno) { |
| 1167 | errors += " (SSL_error_code = " + to_string(sslerrno) + ")"; |
| 1168 | if (sslerrno == SSL_ERROR_SYSCALL) { |
| 1169 | char buf[4096]; |
| 1170 | int err; |
| 1171 | while ((err = ERR_get_error()) != 0) { |
| 1172 | errors += " "; |
| 1173 | errors += ERR_error_string(err, buf); |
| 1174 | } |
| 1175 | } |
| 1176 | } |
| 1177 | } |
| 1178 | |
| 1179 | /** |
| 1180 | * Default implementation of AccessManager |
no test coverage detected