diff --git a/doc/html/md_README.generic-table.html b/doc/html/md_README.generic-table.html new file mode 100644 index 00000000..cae3cbaa --- /dev/null +++ b/doc/html/md_README.generic-table.html @@ -0,0 +1,95 @@ + + + + + + +libwebsockets: Notes about generic-table + + + + + + + + + + + +
+
+ + + + + + + +
+
libwebsockets +
+
Lightweight C library for HTML5 websockets
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+
Notes about generic-table
+
+
+

What is generic-table?

+

Generic-table is a JSON schema and client-side JS file that makes it easy to display live, table structured HTML over a ws link.

+

An example plugin and index.html using it are provided.

+

Enabling for build

+

Enable at CMake with -DLWS_WITH_PLUGINS=1

+

Generic-table JSON

+

Column layout

+

When the ws connection is established, the protocol should send a JSON message describing the table columns. For example

+
1 msg = "{\"cols\":["
2  " {\"name\": \"Date\"},"
3  " {\"name\": \"Size\", \"align\": \"right\"},"
4  " {\"name\": \"Icon\"},"
5  " {\"name\": \"Name\", \"href\": \"uri\"},"
6  " {\"name\": \"uri\", \"hide\": \"1\" }"
7  " ]"
8  "}";
    +
  • This describes 5 columns
  • +
  • Only four columns (not "uri") should be visible
  • +
  • "Name" should be presented as a clickable link using "uri" as the destination, when a "uri" field is presented.
  • +
  • "Size" field should be presented aligned to the right
  • +
+

Table data

+

The

+
+
+ + + + diff --git a/doc/html/md_README.problems.html b/doc/html/md_README.problems.html new file mode 100644 index 00000000..d93138b6 --- /dev/null +++ b/doc/html/md_README.problems.html @@ -0,0 +1,104 @@ + + + + + + +libwebsockets: Debugging problems + + + + + + + + + + + +
+
+ + + + + + + +
+
libwebsockets +
+
Lightweight C library for HTML5 websockets
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+
Debugging problems
+
+
+

Library is a component

+

As a library, lws is just a component in a bigger application.

+

Many users are able to share their sources, but others decide not to, for "commerical advantage" or whatever.

+

This makes answering questions like "what is wrong with my code I am not +going to show you?" very difficult.

+

Even if it's clear there is a problem somewhere, it cannot be understood or reproduced by anyone else if it needs user code that isn't provided.

+

The biggest question is, "is this an lws problem actually"?

+

Use the test apps as sanity checks

+

The test server and client are extremely useful for sanity checks and debugging guidance.

+
    +
  • test apps work on your platform, then either
      +
    • your user code is broken, align it to how the test apps work, or,
    • +
    • something from your code is required to show an lws problem, provide a minimal patch on a test app so it can be reproduced
    • +
    +
  • +
  • test apps break on your platform, but work on, eg, x86_64, either
      +
    • toolchain or platform-specific (eg, OS) issue, or
    • +
    • lws platform support issue
    • +
    +
  • +
  • test apps break everywhere
      +
    • sounds like lws problem, info to reproduce and / or a patch is appreciated
    • +
    +
  • +
+
+
+ + + + diff --git a/doc/latex/md_README.generic-table.tex b/doc/latex/md_README.generic-table.tex new file mode 100644 index 00000000..06008e66 --- /dev/null +++ b/doc/latex/md_README.generic-table.tex @@ -0,0 +1,40 @@ +\subsection*{What is generic-\/table? } + +Generic-\/table is a J\+S\+ON schema and client-\/side JS file that makes it easy to display live, table structured H\+T\+ML over a ws link. + +An example plugin and index.\+html using it are provided. + +\subsection*{Enabling for build } + +Enable at C\+Make with -\/\+D\+L\+W\+S\+\_\+\+W\+I\+T\+H\+\_\+\+P\+L\+U\+G\+I\+NS=1 + +\subsection*{Generic-\/table J\+S\+ON } + +\subsubsection*{Column layout} + +When the ws connection is established, the protocol should send a J\+S\+ON message describing the table columns. For example + + +\begin{DoxyCode} +1 msg = "\{\(\backslash\)"cols\(\backslash\)":[" +2 " \{\(\backslash\)"name\(\backslash\)": \(\backslash\)"Date\(\backslash\)"\}," +3 " \{\(\backslash\)"name\(\backslash\)": \(\backslash\)"Size\(\backslash\)", \(\backslash\)"align\(\backslash\)": \(\backslash\)"right\(\backslash\)"\}," +4 " \{\(\backslash\)"name\(\backslash\)": \(\backslash\)"Icon\(\backslash\)"\}," +5 " \{\(\backslash\)"name\(\backslash\)": \(\backslash\)"Name\(\backslash\)", \(\backslash\)"href\(\backslash\)": \(\backslash\)"uri\(\backslash\)"\}," +6 " \{\(\backslash\)"name\(\backslash\)": \(\backslash\)"uri\(\backslash\)", \(\backslash\)"hide\(\backslash\)": \(\backslash\)"1\(\backslash\)" \}" +7 " ]" +8 "\}"; +\end{DoxyCode} + + + +\begin{DoxyItemize} +\item This describes 5 columns +\item Only four columns (not \char`\"{}uri\char`\"{}) should be visible +\item \char`\"{}\+Name\char`\"{} should be presented as a clickable link using \char`\"{}uri\char`\"{} as the destination, when a \char`\"{}uri\char`\"{} field is presented. +\item \char`\"{}\+Size\char`\"{} field should be presented aligned to the right +\end{DoxyItemize} + +\subsubsection*{Table data} + +The \ No newline at end of file diff --git a/doc/latex/md_README.problems.tex b/doc/latex/md_README.problems.tex new file mode 100644 index 00000000..4ad0e9b0 --- /dev/null +++ b/doc/latex/md_README.problems.tex @@ -0,0 +1,34 @@ +\subsection*{Library is a component } + +As a library, lws is just a component in a bigger application. + +Many users are able to share their sources, but others decide not to, for \char`\"{}commerical advantage\char`\"{} or whatever. + +This makes answering questions like \char`\"{}what is wrong with my code I am not +going to show you?\char`\"{} very difficult. + +Even if it\textquotesingle{}s clear there is a problem somewhere, it cannot be understood or reproduced by anyone else if it needs user code that isn\textquotesingle{}t provided. + +The biggest question is, \char`\"{}is this an lws problem actually\char`\"{}? + +\subsection*{Use the test apps as sanity checks } + +The test server and client are extremely useful for sanity checks and debugging guidance. + + +\begin{DoxyItemize} +\item test apps work on your platform, then either +\begin{DoxyItemize} +\item your user code is broken, align it to how the test apps work, or, +\item something from your code is required to show an lws problem, provide a minimal patch on a test app so it can be reproduced +\end{DoxyItemize} +\item test apps break on your platform, but work on, eg, x86\+\_\+64, either +\begin{DoxyItemize} +\item toolchain or platform-\/specific (eg, OS) issue, or +\item lws platform support issue +\end{DoxyItemize} +\item test apps break everywhere +\begin{DoxyItemize} +\item sounds like lws problem, info to reproduce and / or a patch is appreciated +\end{DoxyItemize} +\end{DoxyItemize} \ No newline at end of file diff --git a/lib/lws-plat-win.c b/lib/lws-plat-win.c index 500f327b..a70e5ab3 100644 --- a/lib/lws-plat-win.c +++ b/lib/lws-plat-win.c @@ -150,56 +150,47 @@ LWS_VISIBLE DWORD lws_plat_wait_event(struct lws_context_per_thread* pt, int timeout) { int event_count = pt->fds_count + 1; - HANDLE* events = pt->events; + HANDLE *events = pt->events; DWORD ev; // the WSAWaitForMultipleEvents can wait for maximum of 64 handles - if(event_count <= WSA_MAXIMUM_WAIT_EVENTS) - { - return ev = WSAWaitForMultipleEvents(event_count, events, - FALSE, timeout, FALSE); - } - else - { - // back-up solution - // this is really ugly and introduces unneeded latency / unfairness - // but still better than the current crash - int timeout_left = timeout; + if (event_count <= WSA_MAXIMUM_WAIT_EVENTS) + return WSAWaitForMultipleEvents(event_count, events, FALSE, + timeout, FALSE); - // the smaller the step the closer we get to the valid solution - // and the more CPU we will use - int timeout_step = (timeout > 20) ? 20 : timeout; + /* you should use libuv instead of this */ + int timeout_left = timeout; - while(timeout_left > 0) - { - int events_left = event_count; - int events_handled = 0; - timeout = 0; + // the smaller the step the closer we get to the valid solution + // and the more CPU we will use + int timeout_step = (timeout > 20) ? 20 : timeout; - while(events_left > 0) - { - // split to groups to size of max 64 - int events_to_handle = (events_left > WSA_MAXIMUM_WAIT_EVENTS) ? - WSA_MAXIMUM_WAIT_EVENTS : - events_left; + do { + int events_left = event_count; + int events_handled = 0; + timeout = 0; - // wait only on the last group - if(events_left == events_to_handle) - timeout = timeout_step; + while (events_left > 0) { + // split to groups to size of max 64 + int rem = (events_left > WSA_MAXIMUM_WAIT_EVENTS) ? + WSA_MAXIMUM_WAIT_EVENTS : events_left; - ev = WSAWaitForMultipleEvents(events_to_handle, &events[events_handled], - FALSE, timeout, FALSE); + // wait only on the last group + if (events_left == rem) + timeout = timeout_step; - if(ev != WSA_WAIT_TIMEOUT) - return ev + events_handled; + ev = WSAWaitForMultipleEvents(rem, &events[events_handled], + FALSE, timeout, FALSE); - events_handled += events_to_handle; - events_left -= events_to_handle; - } + if (ev != WSA_WAIT_TIMEOUT) + return ev + events_handled; - timeout_left -= timeout_step; + events_handled += rem; + events_left -= rem; } - } + + timeout_left -= timeout_step; + } while (timeout_left > 0); return WSA_WAIT_TIMEOUT; }