summaryrefslogtreecommitdiffstats
path: root/contrib/src
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-01-27 19:30:19 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-01-27 19:30:19 (GMT)
commit95c3505e11d22f9a022647b0c7383364682d91de (patch)
tree9c2265bb944ebb872411e7bad7d2b602e62a9704 /contrib/src
parente1f59bb39d4722d0693e22b362ba834256f4d79c (diff)
downloaduscxml-95c3505e11d22f9a022647b0c7383364682d91de.zip
uscxml-95c3505e11d22f9a022647b0c7383364682d91de.tar.gz
uscxml-95c3505e11d22f9a022647b0c7383364682d91de.tar.bz2
Bug fixes and thread safety for web sockets
Diffstat (limited to 'contrib/src')
-rw-r--r--contrib/src/evws/evws.c16
-rw-r--r--contrib/src/evws/evws.h1
2 files changed, 14 insertions, 3 deletions
diff --git a/contrib/src/evws/evws.c b/contrib/src/evws/evws.c
index 8932b9f..a2cc992 100644
--- a/contrib/src/evws/evws.c
+++ b/contrib/src/evws/evws.c
@@ -143,6 +143,16 @@ void evws_broadcast(struct evws *ws, const char *uri, enum evws_opcode opcode, c
}
}
+int evws_is_valid_connection(struct evws *ws, struct evws_connection *conn) {
+ struct evws_connection *ws_connection;
+ for ((ws_connection) = (&ws->connections)->tqh_first; ws_connection; ws_connection = ws_connection->next.tqe_next) {
+ if (ws_connection == conn)
+ return 1;
+ }
+ return 0;
+}
+
+
// Error callback
static void cb_error(struct bufferevent *bev, short what, void *ctx) {
struct evws_connection *conn = ctx;
@@ -374,7 +384,7 @@ NEXT_FRAME:
while(conn->frame->payload_bytes > 0 && // need to add more bytes to the payload length
(size - (dataPtr - readbuf) > 0)) { // and bytes still available
// length is in MSB network order - shift to left and add
- conn->frame->size = (conn->frame->size << 8) + dataPtr[0];
+ conn->frame->size = (conn->frame->size << 8) + (uint8_t)dataPtr[0];
conn->frame->payload_bytes--;
dataPtr++;
}
@@ -427,9 +437,9 @@ NEXT_FRAME:
// TAILQ_FOREACH
for (ws_cb = ((&ws->callbacks))->tqh_first; ws_cb; ws_cb = (ws_cb->next.tqe_next)) {
if (strcmp(ws_cb->uri, conn->uri) == 0) {
- if(ws_cb->msg_cb != ((void*)0))
+ if(ws_cb->msg_cb != ((void*)0)) {
ws_cb->msg_cb(conn, conn->frame, ws_cb->cb_arg);
- return;
+ }
}
}
ws->gencb(conn, conn->frame, ws->gencb_arg);
diff --git a/contrib/src/evws/evws.h b/contrib/src/evws/evws.h
index f9ea567..d32c3e1 100644
--- a/contrib/src/evws/evws.h
+++ b/contrib/src/evws/evws.h
@@ -194,6 +194,7 @@ struct evws {
struct evws_connection *evws_connection_new(struct evws *ws, evutil_socket_t fd);
void evws_connection_free(struct evws_connection *conn);
+int evws_is_valid_connection(struct evws *ws, struct evws_connection *conn);
struct evws_frame *evws_frame_new();
void evws_frame_free(struct evws_frame *frame);