|
@@ -10226,16 +10226,20 @@ mg_websocket_write_exec(struct mg_connection *conn,
|
|
* but mongoose's mg_printf/mg_write is not (because of the loop in
|
|
* but mongoose's mg_printf/mg_write is not (because of the loop in
|
|
* push(), although that is only a problem if the packet is large or
|
|
* push(), although that is only a problem if the packet is large or
|
|
* outgoing buffer is full). */
|
|
* outgoing buffer is full). */
|
|
|
|
+
|
|
/* TODO: Check if this lock should be moved to user land.
|
|
/* TODO: Check if this lock should be moved to user land.
|
|
* Currently the server sets this lock for websockets, but
|
|
* Currently the server sets this lock for websockets, but
|
|
* not for any other connection. It must be set for every
|
|
* not for any other connection. It must be set for every
|
|
* conn read/written by more than one thread, no matter if
|
|
* conn read/written by more than one thread, no matter if
|
|
* it is a websocket or regular connection. */
|
|
* it is a websocket or regular connection. */
|
|
(void)mg_lock_connection(conn);
|
|
(void)mg_lock_connection(conn);
|
|
|
|
+
|
|
retval = mg_write(conn, header, headerLen);
|
|
retval = mg_write(conn, header, headerLen);
|
|
if (dataLen > 0) {
|
|
if (dataLen > 0) {
|
|
retval = mg_write(conn, data, dataLen);
|
|
retval = mg_write(conn, data, dataLen);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /* TODO: Remove this unlock as well, when lock is moved. */
|
|
mg_unlock_connection(conn);
|
|
mg_unlock_connection(conn);
|
|
|
|
|
|
return retval;
|
|
return retval;
|
|
@@ -13361,7 +13365,7 @@ mg_close_connection(struct mg_connection *conn)
|
|
mg_free(client_ctx);
|
|
mg_free(client_ctx);
|
|
(void)pthread_mutex_destroy(&conn->mutex);
|
|
(void)pthread_mutex_destroy(&conn->mutex);
|
|
mg_free(conn);
|
|
mg_free(conn);
|
|
- } else if (conn->ctx->context_type == 0) {//Client
|
|
|
|
|
|
+ } else if (conn->ctx->context_type == 0) { // Client
|
|
mg_free(conn);
|
|
mg_free(conn);
|
|
}
|
|
}
|
|
}
|
|
}
|