summaryrefslogtreecommitdiff
path: root/res/res_http_websocket.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2015-08-04 09:47:34 -0500
committerMark Michelson <mmichelson@digium.com>2015-08-04 10:19:36 -0500
commitc63316eec10e1990a88bf4712238d6deb375bfa9 (patch)
tree7ae5c0e73f594274175ec8ec8521a435de2c9458 /res/res_http_websocket.c
parent3ba6099a9e20cd6a1bf0c9a903335bee6e1e7228 (diff)
res_http_websocket: Debug write lengths.
Commit 39cc28f6ea2140ad6d561fd4c9e9a66f065cecee attempted to fix a test failure observed on 32 bit test agents by ensuring that a cast from a 32 bit unsigned integer to a 64 bit unsigned integer was happening in a predictable place. As it turns out, this did not cause test runs to succeed. This commit adds several redundant debug messages that print the payload lengths of websocket frames. The idea here is that this commit will not cause tests to succeed for the faulty test agent, but we might deduce where the fault lies more easily this way by observing at what point the expected value (537) changes to some ungangly huge number. If you are wondering why something like this is being committed to the branch, keep in mind that in commit 39cc28f6ea2140ad6d561fd4c9e9a66f065cecee I noted that the observed test failures only happen when automated tests are run. Attempts to run the tests by hand manually on the test agent result in the tests passing. Change-Id: I14a65c19d8af40dadcdbd52348de3b0016e1ae8d
Diffstat (limited to 'res/res_http_websocket.c')
-rw-r--r--res/res_http_websocket.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 33905452f..9e5c60d83 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -300,6 +300,24 @@ int AST_OPTIONAL_API_NAME(ast_websocket_close)(struct ast_websocket *session, ui
return res;
}
+static const char *opcode_map[] = {
+ [AST_WEBSOCKET_OPCODE_CONTINUATION] = "continuation",
+ [AST_WEBSOCKET_OPCODE_TEXT] = "text",
+ [AST_WEBSOCKET_OPCODE_BINARY] = "binary",
+ [AST_WEBSOCKET_OPCODE_CLOSE] = "close",
+ [AST_WEBSOCKET_OPCODE_PING] = "ping",
+ [AST_WEBSOCKET_OPCODE_PONG] = "pong",
+};
+
+static const char *websocket_opcode2str(enum ast_websocket_opcode opcode)
+{
+ if (opcode < AST_WEBSOCKET_OPCODE_CONTINUATION ||
+ opcode > AST_WEBSOCKET_OPCODE_PONG) {
+ return "<unknown>";
+ } else {
+ return opcode_map[opcode];
+ }
+}
/*! \brief Write function for websocket traffic */
int AST_OPTIONAL_API_NAME(ast_websocket_write)(struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t actual_length)
@@ -308,6 +326,9 @@ int AST_OPTIONAL_API_NAME(ast_websocket_write)(struct ast_websocket *session, en
char *frame;
uint64_t length;
+ ast_debug(3, "Writing websocket %s frame, length %" PRIu64 "\n",
+ websocket_opcode2str(opcode), actual_length);
+
if (actual_length < 126) {
length = actual_length;
} else if (actual_length < (1 << 16)) {
@@ -1372,6 +1393,8 @@ int AST_OPTIONAL_API_NAME(ast_websocket_write_string)
{
uint64_t len = strlen(buf);
+ ast_debug(3, "Writing websocket string of length %" PRIu64 "\n", len);
+
/* We do not pass strlen(buf) to ast_websocket_write() directly because the
* size_t returned by strlen() may not require the same storage size
* as the uint64_t that ast_websocket_write() uses. This normally