event libs: h1 pipelining needs to manage event lib additional data during handover too
diff --git a/lib/core-net/wsi.c b/lib/core-net/wsi.c
index 78e086e..2130525 100644
--- a/lib/core-net/wsi.c
+++ b/lib/core-net/wsi.c
@@ -822,6 +822,8 @@
 
 	assert(lws_socket_is_valid(wsi->desc.sockfd));
 
+	__lws_change_pollfd(wsi, LWS_POLLOUT | LWS_POLLIN, 0);
+
 	/* copy the fd */
 	wnew->desc = wsi->desc;
 
@@ -833,6 +835,21 @@
 		return -1;
 	wsi->desc.sockfd = LWS_SOCK_INVALID;
 
+	/*
+	 * ... we're doing some magic here in terms of handing off the socket
+	 * that has been active to a wsi that has not yet itself been active...
+	 * depending on the event lib we may need to give a magic spark to the
+	 * new guy and snuff out the old guy's magic spark at that level as well
+	 */
+
+#if defined(LWS_WITH_LIBEV) || defined(LWS_WITH_LIBUV) || \
+    defined(LWS_WITH_LIBEVENT) || defined(LWS_WITH_GLIB)
+	if (wsi->context->event_loop_ops->destroy_wsi)
+		wsi->context->event_loop_ops->destroy_wsi(wsi);
+	if (wsi->context->event_loop_ops->sock_accept)
+		wsi->context->event_loop_ops->sock_accept(wnew);
+#endif
+
 	/* point the fd table entry to new guy */
 
 	assert(lws_socket_is_valid(wnew->desc.sockfd));
diff --git a/lib/event-libs/glib/glib.c b/lib/event-libs/glib/glib.c
index 9229296..af42dc8 100644
--- a/lib/event-libs/glib/glib.c
+++ b/lib/event-libs/glib/glib.c
@@ -352,6 +352,11 @@
 	lwsl_debug("%s: wsi %p, fd %d, 0x%x/0x%x\n", __func__, wsi,
 			wsi->desc.sockfd, flags, (int)cond);
 
+	if (!wsi_to_subclass(wsi)) {
+		lwsl_err("%s: glib wsi source pointer is NULL\n", __func__);
+		return;
+	}
+
 	g_source_modify_unix_fd(wsi_to_gsource(wsi), wsi_to_subclass(wsi)->tag,
 				cond);
 }