api change deliver socket fd to in param of extpoll callbacks 09/3109/1
authorAndy Green <andy.green@linaro.org>
Fri, 15 Feb 2013 14:36:30 +0000 (22:36 +0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:36 +0000 (13:01 -0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
changelog
lib/libwebsockets.c
lib/libwebsockets.h
libwebsockets-api-doc.html
test-server/test-server.c

index ea3cdf0..a2c46fd 100644 (file)
--- a/changelog
+++ b/changelog
@@ -10,6 +10,14 @@ User api additions
        and get a LWS_CALLBACK_HTTP_WRITEABLE callback, the same way you can
        regulate writes with a websocket protocol connection.
 
+User api changes
+----------------
+
+ - the external poll callbacks now get the socket descriptor coming from the
+       "in" parameter.  The user parameter provides the user_space for the
+       wsi as it normally does on the other callbacks.
+
+
 
 v1.21-chrome26-firefox18
 ========================
index 3dfe3a9..74359a2 100644 (file)
@@ -127,7 +127,7 @@ insert_wsi_socket_into_fds(struct libwebsocket_context *context,
        /* external POLL support via protocol 0 */
        context->protocols[0].callback(context, wsi,
                LWS_CALLBACK_ADD_POLL_FD,
-               (void *)(long)wsi->sock, NULL, POLLIN);
+               wsi->user_space, (void *)(long)wsi->sock, POLLIN);
 
        return 0;
 }
@@ -170,7 +170,8 @@ do_ext:
        /* remove also from external POLL support via protocol 0 */
        if (wsi->sock)
                context->protocols[0].callback(context, wsi,
-                   LWS_CALLBACK_DEL_POLL_FD, (void *)(long)wsi->sock, NULL, 0);
+                   LWS_CALLBACK_DEL_POLL_FD, wsi->user_space,
+                                                   (void *)(long)wsi->sock, 0);
 
        return 0;
 }
@@ -739,7 +740,7 @@ user_service:
                /* external POLL support via protocol 0 */
                context->protocols[0].callback(context, wsi,
                        LWS_CALLBACK_CLEAR_MODE_POLL_FD,
-                       (void *)(long)wsi->sock, NULL, POLLOUT);
+                       wsi->user_space, (void *)(long)wsi->sock, POLLOUT);
        }
 #ifndef LWS_NO_EXTENSIONS
 notify_action:
@@ -1312,7 +1313,7 @@ libwebsocket_callback_on_writable(struct libwebsocket_context *context,
        /* external POLL support via protocol 0 */
        context->protocols[0].callback(context, wsi,
                LWS_CALLBACK_SET_MODE_POLL_FD,
-               (void *)(long)wsi->sock, NULL, POLLOUT);
+               wsi->user_space, (void *)(long)wsi->sock, POLLOUT);
 
        return 1;
 }
@@ -1468,12 +1469,12 @@ _libwebsocket_rx_flow_control(struct libwebsocket *wsi)
                /* external POLL support via protocol 0 */
                context->protocols[0].callback(context, wsi,
                        LWS_CALLBACK_SET_MODE_POLL_FD,
-                       (void *)(long)wsi->sock, NULL, POLLIN);
+                       wsi->user_space, (void *)(long)wsi->sock, POLLIN);
        else
                /* external POLL support via protocol 0 */
                context->protocols[0].callback(context, wsi,
                        LWS_CALLBACK_CLEAR_MODE_POLL_FD,
-                       (void *)(long)wsi->sock, NULL, POLLIN);
+                       wsi->user_space, (void *)(long)wsi->sock, POLLIN);
 
        return 1;
 }
index 3b1e837..e1c04cc 100644 (file)
@@ -568,24 +568,24 @@ struct libwebsocket_extension;
  *             poll array interface code in the callback for protocol 0, the
  *             first protocol you support, usually the HTTP protocol in the
  *             serving case.  This callback happens when a socket needs to be
- *             added to the polling loop: @user contains the fd, and
+ *             added to the polling loop: @in contains the fd, and
  *             @len is the events bitmap (like, POLLIN).  If you are using the
  *             internal polling loop (the "service" callback), you can just
  *             ignore these callbacks.
  *
  *     LWS_CALLBACK_DEL_POLL_FD: This callback happens when a socket descriptor
- *             needs to be removed from an external polling array.  @user is
+ *             needs to be removed from an external polling array.  @in is
  *             the socket desricptor.  If you are using the internal polling
  *             loop, you can just ignore it.
  *
  *     LWS_CALLBACK_SET_MODE_POLL_FD: This callback happens when libwebsockets
- *             wants to modify the events for the socket descriptor in @user.
+ *             wants to modify the events for the socket descriptor in @in.
  *             The handler should OR @len on to the events member of the pollfd
  *             struct for this socket descriptor.  If you are using the
  *             internal polling loop, you can just ignore it.
  *
  *     LWS_CALLBACK_CLEAR_MODE_POLL_FD: This callback occurs when libwebsockets
- *             wants to modify the events for the socket descriptor in @user.
+ *             wants to modify the events for the socket descriptor in @in.
  *             The handler should AND ~@len on to the events member of the
  *             pollfd struct for this socket descriptor.  If you are using the
  *             internal polling loop, you can just ignore it.
index 7fd8702..306f18e 100644 (file)
@@ -785,7 +785,7 @@ serving case.  This callback happens when a socket needs to be
 </blockquote>
 <h3>added to the polling loop</h3>
 <blockquote>
-<tt><b>user</b></tt> contains the fd, and
+<tt><b>in</b></tt> contains the fd, and
 <tt><b>len</b></tt> is the events bitmap (like, POLLIN).  If you are using the
 internal polling loop (the "service" callback), you can just
 ignore these callbacks.
@@ -793,14 +793,14 @@ ignore these callbacks.
 <h3>LWS_CALLBACK_DEL_POLL_FD</h3>
 <blockquote>
 This callback happens when a socket descriptor
-needs to be removed from an external polling array.  <tt><b>user</b></tt> is
+needs to be removed from an external polling array.  <tt><b>in</b></tt> is
 the socket desricptor.  If you are using the internal polling
 loop, you can just ignore it.
 </blockquote>
 <h3>LWS_CALLBACK_SET_MODE_POLL_FD</h3>
 <blockquote>
 This callback happens when libwebsockets
-wants to modify the events for the socket descriptor in <tt><b>user</b></tt>.
+wants to modify the events for the socket descriptor in <tt><b>in</b></tt>.
 The handler should OR <tt><b>len</b></tt> on to the events member of the pollfd
 struct for this socket descriptor.  If you are using the
 internal polling loop, you can just ignore it.
@@ -808,7 +808,7 @@ internal polling loop, you can just ignore it.
 <h3>LWS_CALLBACK_CLEAR_MODE_POLL_FD</h3>
 <blockquote>
 This callback occurs when libwebsockets
-wants to modify the events for the socket descriptor in <tt><b>user</b></tt>.
+wants to modify the events for the socket descriptor in <tt><b>in</b></tt>.
 The handler should AND ~<tt><b>len</b></tt> on to the events member of the
 pollfd struct for this socket descriptor.  If you are using the
 internal polling loop, you can just ignore it.
index 246c1b8..27208e0 100644 (file)
@@ -129,7 +129,7 @@ static int callback_http(struct libwebsocket_context *context,
        struct per_session_data__http *pss = (struct per_session_data__http *)user;
 #ifdef EXTERNAL_POLL
        int m;
-       int fd = (int)(long)user;
+       int fd = (int)(long)in;
 #endif
 
        switch (reason) {