[Libwebsockets] [libwebsockets] #107: Missing LWS_CALLBACK_CLOSED on the the server

Trac trac at libwebsockets.org
Sat Apr 11 03:18:21 CEST 2015


#107: Missing LWS_CALLBACK_CLOSED on the the server
------------------------------------+-----------------
  Reporter:  stephang               |      Owner:
      Type:  defect                 |     Status:  new
  Priority:  major                  |  Milestone:
 Component:  libwebsockets library  |    Version:
Resolution:                         |   Keywords:
------------------------------------+-----------------

Comment (by agreen):

 I can't reproduce that.

 From what I understood this patch using the test server and client should
 show it

 diff --git a/test-server/test-client.c b/test-server/test-client.c
 index 73cd7d8..e91782a 100644
 --- a/test-server/test-client.c
 +++ b/test-server/test-client.c
 @@ -37,7 +37,7 @@

  #include "../lib/libwebsockets.h"

 -static unsigned int opts;
 +//static unsigned int opts;
  static int was_closed;
  static int deny_deflate;
  static int deny_mux;
 @@ -133,10 +133,10 @@ callback_lws_mirror(struct libwebsocket_context
 *context,
                         enum libwebsocket_callback_reasons reason,
                                                void *user, void *in,
 size_t len)
  {
 -       unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 4096 +
 -
 LWS_SEND_BUFFER_POST_PADDING];
 -       int l = 0;
 -       int n;
 +//     unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 4096 +
 +//
 LWS_SEND_BUFFER_POST_PADDING];
 +//     int l = 0;
 +//     int n;
         unsigned int rands[4];

         switch (reason) {
 @@ -179,7 +179,7 @@ callback_lws_mirror(struct libwebsocket_context
 *context,
                 break;

         case LWS_CALLBACK_CLIENT_WRITEABLE:
 -
 +#if 0
                 for (n = 0; n < 1; n++) {
                         libwebsockets_get_random(context, rands,
 sizeof(rands));
                         l += sprintf((char
 *)&buf[LWS_SEND_BUFFER_PRE_PADDING + l],
 @@ -207,6 +207,7 @@ callback_lws_mirror(struct libwebsocket_context
 *context,
                 } else
                         /* get notified as soon as we can write again */
                         libwebsocket_callback_on_writable(context, wsi);
 +#endif
                 break;

         default:
 diff --git a/test-server/test-server.c b/test-server/test-server.c
 index b321ff8..2e10b5d 100644
 --- a/test-server/test-server.c
 +++ b/test-server/test-server.c
 @@ -938,7 +938,7 @@ int main(int argc, char **argv)

                 ms = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
                 if ((ms - oldms) > 50) {
 -
 libwebsocket_callback_on_writable_all_protocol(&protocols[PROTOCOL_DUMB_INCREMENT]);
 +       //
 libwebsocket_callback_on_writable_all_protocol(&protocols[PROTOCOL_DUMB_INCREMENT]);
                         oldms = ms;
                 }



 When I ^C the client (who did nothing for tx or rx after ws established) I
 see this at the server

 lwsts[21301]: callback_lws_mirror: LWS_CALLBACK_ESTABLISHED
 lwsts[21301]: Allocating RX buffer 150
 lwsts[21301]: accepted v13 connection
 ...
 lwsts[21301]: libwebsocket_read: read_ok
 lwsts[21301]: service_fd: closing due to 0 length read
 lwsts[21301]: Close and handled
 lwsts[21301]: close: just_kill_connection
 lwsts[21301]: remove_wsi_socket_from_fds: wsi=0xebd3c0, sock=8, fds pos=2
 lwsts[21301]: calling back CLOSED
 lwsts[21301]: zlibs destructed
 lwsts[21301]: zlibs destructed
 lwsts[21301]: service_fd: closing due to 0 length read
 lwsts[21301]: Close and handled
 lwsts[21301]: close: just_kill_connection
 lwsts[21301]: remove_wsi_socket_from_fds: wsi=0xebdff0, sock=9, fds pos=2
 lwsts[21301]: calling back CLOSED
 lwsts[21301]: zlibs destructed
 lwsts[21301]: zlibs destructed

 The client said this (ie, also acted well)

 ^CExiting
 [1428714627:4161] NOTICE: libwebsocket_context_destroy
 [1428714627:4161] DEBUG: close: just_kill_connection
 [1428714627:4161] INFO: remove_wsi_socket_from_fds: wsi=0x118ef70, sock=6,
 fds pos=1
 [1428714627:4161] DEBUG: calling back CLOSED
 LWS_CALLBACK_CLOSED
 [1428714627:4161] EXTENSION: zlibs destructed
 [1428714627:4161] EXTENSION: zlibs destructed
 [1428714627:4162] DEBUG: close: just_kill_connection
 [1428714627:4162] INFO: remove_wsi_socket_from_fds: wsi=0x118f120, sock=7,
 fds pos=1
 [1428714627:4162] DEBUG: calling back CLOSED
 mirror: LWS_CALLBACK_CLOSED mirror_lifetime=359
 [1428714627:4162] EXTENSION: zlibs destructed
 [1428714627:4162] EXTENSION: zlibs destructed

 Please try the same test using current git HEAD and the test patch on your
 platform.

--
Ticket URL: <http://libwebsockets.org/trac/libwebsockets/ticket/107#comment:3>
libwebsockets <http://libwebsockets.org>
libwebsockets C library



More information about the Libwebsockets mailing list