[Libwebsockets] [libwebsockets] #87: Return value from callback is ignored

Trac trac at libwebsockets.org
Wed Oct 1 02:50:42 CEST 2014


#87: Return value from callback is ignored
-----------------------------------+------------------------
 Reporter:  dimitrirostavo         |      Owner:
     Type:  defect                 |     Status:  new
 Priority:  major                  |  Milestone:  milestone1
Component:  libwebsockets library  |    Version:  1.0
 Keywords:                         |
-----------------------------------+------------------------
 We call the callback inside handshake_0405(struct libwebsocket_context
 *context, struct libwebsocket *wsi) method in server-handshake.c line 267

 if (wsi->protocol->callback)
    wsi->protocol->callback(wsi->protocol->owning_server,
                                 wsi, LWS_CALLBACK_ESTABLISHED,
                                           wsi->user_space, NULL, 0))

 The return value from the callback is ignored.

 Expected result:
 Should a nonzero value be returned from the callback we should call "goto
 bail;"

 The code should look like
 if (wsi->protocol->callback)
     {
                 if(wsi->protocol->callback(wsi->protocol->owning_server,
                                 wsi, LWS_CALLBACK_ESTABLISHED,
                                           wsi->user_space, NULL, 0))
         {
             lwsl_debug("handshake_0405: Callback returned an error\n");
                         goto bail;
         }
     }

--
Ticket URL: <http://libwebsockets.org/trac/libwebsockets/ticket/87>
libwebsockets <http://libwebsockets.org>
libwebsockets C library



More information about the Libwebsockets mailing list