/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the <sys/prctl.h> header file. */
+#undef HAVE_SYS_PRCTL_H
+
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
# Checks for header files.
-for ac_header in zlib.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h
+for ac_header in zlib.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h sys/prctl.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
wsi->mode = LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE;
pfd.fd = wsi->sock;
pfd.revents = POLLIN;
- libwebsocket_service_fd(context, &pfd);
+ if (libwebsocket_service_fd(context, &pfd) < 0)
+ goto oom4;
return wsi;
accept_fd = accept(pollfd->fd, (struct sockaddr *)&cli_addr,
&clilen);
if (accept_fd < 0) {
- fprintf(stderr, "ERROR on accept");
- break;
+ debug("ERROR on accept\n");
+ return -1;
}
/* Disable Nagle */
accept_fd = accept(pollfd->fd, (struct sockaddr *)&cli_addr,
&clilen);
if (accept_fd < 0) {
- fprintf(stderr, "ERROR on accept");
- break;
+ debug("ERROR on accept\n");
+ return -1;
}
if (context->fds_count >= MAX_CLIENTS) {
/*
fprintf(stderr, "Listen Socket dead\n");
*/
- return 1;
+ return -1;
}
/* handle accept on listening socket? */
for (n = 0; n < context->fds_count; n++)
if (context->fds[n].revents)
- libwebsocket_service_fd(context, &context->fds[n]);
-
+ if (libwebsocket_service_fd(context,
+ &context->fds[n]) < 0)
+ return -1;
return 0;
}
while (1) {
if (libwebsocket_service(context, 1000))
- return -1;
+ break;
#ifndef HAVE_SYS_PRCTL_H
/*
* on systems without prctl() (i.e. anything but linux) we can notice that our
}
- return 0;
+ return 1;
}
#endif
while (n >= 0 && !was_closed) {
n = libwebsocket_service(context, 1000);
+ if (n < 0)
+ continue;
+
if (wsi_mirror == NULL) {
/* create a client websocket using mirror protocol */
* match anything under libwebsockets
* control
*/
- libwebsocket_service_fd(context,
- &pollfds[n]);
+ if (libwebsocket_service_fd(context,
+ &pollfds[n]))
+ goto done;
/* do our broadcast periodically */
fprintf(stderr, " Using no-fork service loop\n");
- while (1) {
+ n = 0;
+ while (n >= 0) {
struct timeval tv;
gettimeofday(&tv, NULL);
* "manually".
*
* If no socket is needing service, the call below returns
- * immediately and quickly.
+ * immediately and quickly. Negative return means we are
+ * in process of closing
*/
- libwebsocket_service(context, 50);
+ n = libwebsocket_service(context, 50);
}
#else