patch-libfcgi_os_unix_c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. $OpenBSD: patch-libfcgi_os_unix_c,v 1.4 2015/02/06 14:55:41 sthen Exp $
  2. select->poll conversion, modified from patch at
  3. https://bugs.launchpad.net/ubuntu/+source/libfcgi/+bug/933417
  4. (difference: don't use env variables to control timeouts)
  5. --- libfcgi/os_unix.c.orig Tue Mar 5 19:14:49 2002
  6. +++ libfcgi/os_unix.c Fri Feb 6 11:51:00 2015
  7. @@ -42,6 +42,7 @@ static const char rcsid[] = "$Id: os_unix.c,v 1.37 200
  8. #include <sys/time.h>
  9. #include <sys/un.h>
  10. #include <signal.h>
  11. +#include <poll.h>
  12. #ifdef HAVE_NETDB_H
  13. #include <netdb.h>
  14. @@ -103,6 +104,9 @@ static int volatile maxFd = -1;
  15. static int shutdownPending = FALSE;
  16. static int shutdownNow = FALSE;
  17. +static int libfcgiOsClosePollTimeout = 2000;
  18. +static int libfcgiIsAfUnixKeeperPollTimeout = 2000;
  19. +
  20. void OS_ShutdownPending()
  21. {
  22. shutdownPending = TRUE;
  23. @@ -755,19 +759,16 @@ int OS_Close(int fd)
  24. if (shutdown(fd, 1) == 0)
  25. {
  26. - struct timeval tv;
  27. - fd_set rfds;
  28. + struct pollfd pfd;
  29. int rv;
  30. char trash[1024];
  31. - FD_ZERO(&rfds);
  32. + pfd.fd = fd;
  33. + pfd.events = POLLIN;
  34. do
  35. {
  36. - FD_SET(fd, &rfds);
  37. - tv.tv_sec = 2;
  38. - tv.tv_usec = 0;
  39. - rv = select(fd + 1, &rfds, NULL, NULL, &tv);
  40. + rv = poll(&pfd, 1, libfcgiOsClosePollTimeout);
  41. }
  42. while (rv > 0 && read(fd, trash, sizeof(trash)) > 0);
  43. }
  44. @@ -1116,13 +1117,11 @@ static int is_reasonable_accept_errno (const int error
  45. */
  46. static int is_af_unix_keeper(const int fd)
  47. {
  48. - struct timeval tval = { READABLE_UNIX_FD_DROP_DEAD_TIMEVAL };
  49. - fd_set read_fds;
  50. + struct pollfd pfd;
  51. + pfd.fd = fd;
  52. + pfd.events = POLLIN;
  53. - FD_ZERO(&read_fds);
  54. - FD_SET(fd, &read_fds);
  55. -
  56. - return select(fd + 1, &read_fds, NULL, NULL, &tval) >= 0 && FD_ISSET(fd, &read_fds);
  57. + return poll(&pfd, 1, libfcgiIsAfUnixKeeperPollTimeout) >= 0 && (pfd.revents & POLLIN);
  58. }
  59. /*