* unlock it prior to waiting.
*/
ast_mutex_unlock(&transport->base.read_lock);
- if (ast_websocket_wait_for_input(transport->ws, -1) <= 0) {
+ while (ast_websocket_wait_for_input(transport->ws, -1) <= 0) {
+ /* If this was poll getting interrupted just go back to waiting */
+ if (errno == EINTR || errno == EAGAIN) {
+ continue;
+ }
+
ast_mutex_lock(&transport->base.read_lock);
log_error(self, "poll failure: %s", strerror(errno));
/* Ensure this transport is in a disconnected state */
int has_accept = 0;
int has_protocol = 0;
- if (ast_iostream_gets(client->ser->stream, buf, sizeof(buf)) <= 0) {
+ while (ast_iostream_gets(client->ser->stream, buf, sizeof(buf)) <= 0) {
+ if (errno == EINTR || errno == EAGAIN) {
+ continue;
+ }
+
ast_log(LOG_ERROR, "Unable to retrieve HTTP status line.");
return WS_BAD_STATUS;
}
/* Ignoring line folding - assuming header field values are contained
within a single line */
- while (ast_iostream_gets(client->ser->stream, buf, sizeof(buf)) > 0) {
+ while (1) {
+ ssize_t len = ast_iostream_gets(client->ser->stream, buf, sizeof(buf));
char *name, *value;
- int parsed = ast_http_header_parse(buf, &name, &value);
+ int parsed;
+
+ if (len <= 0) {
+ if (errno == EINTR || errno == EAGAIN) {
+ continue;
+ }
+ break;
+ }
+ parsed = ast_http_header_parse(buf, &name, &value);
if (parsed < 0) {
break;
}
return WS_NOT_SUPPORTED;
}
}
+
return has_upgrade && has_connection && has_accept ?
WS_OK : WS_HEADER_MISSING;
}
ast_test_validate(test, !aeap_transport_is_connected(transport));
- /*
- * The following section of code has been disabled as it may be the cause
- * of subsequent test failures.
- *
- * See ASTERISK-30099 for more information
- */
-
- /* aeap_transport_destroy(transport); */
+ aeap_transport_destroy(transport);
/* /\* Test invalid protocol *\/ */
- /* ast_test_validate(test, (transport = aeap_transport_create(TRANSPORT_URL))); */
+ ast_test_validate(test, (transport = aeap_transport_create(TRANSPORT_URL)));
- /* ast_test_validate(test, aeap_transport_connect(transport, */
- /* TRANSPORT_URL, TRANSPORT_PROTOCOL_INVALID, TRANSPORT_TIMEOUT)); */
+ ast_test_validate(test, aeap_transport_connect(transport,
+ TRANSPORT_URL, TRANSPORT_PROTOCOL_INVALID, TRANSPORT_TIMEOUT));
- /* ast_test_validate(test, !aeap_transport_is_connected(transport)); */
+ ast_test_validate(test, !aeap_transport_is_connected(transport));
return AST_TEST_PASS;
}