diff --git a/lib/service.c b/lib/service.c
index bec262d92d2cd4a4df58d1d14eae92cdee630de2..4c29735537e0adbb476452b9872cf7ebf41b0d65 100644
--- a/lib/service.c
+++ b/lib/service.c
@@ -143,6 +143,8 @@ lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd)
 	/* Priority 6: user can get the callback
 	 */
 	m = lws_ext_cb_active(wsi, LWS_EXT_CB_IS_WRITEABLE, NULL, 0);
+	if (m)
+		return -1;
 #ifndef LWS_NO_EXTENSIONS
 	if (!wsi->extension_data_pending)
 		goto user_service;
diff --git a/test-server/test-server-pthreads.c b/test-server/test-server-pthreads.c
index ed61419d82efb5fd4e41f8beea86206cc5709382..1870ae83687f0fc3a63c1781e24438328bb81484 100644
--- a/test-server/test-server-pthreads.c
+++ b/test-server/test-server-pthreads.c
@@ -360,7 +360,7 @@ int main(int argc, char **argv)
 
 	/* wait for all the service threads to exit */
 
-	for (n = 0; n < lws_get_count_threads(context); n++)
+	while ((--n) >= 0)
 		pthread_join(pthread_service[n], &retval);
 
 	/* wait for pthread_dumb to exit */