Tests about a simple python3 fastcgi runner using libfcgi and the Python-C API.
python
c
wsgi
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ipc.h 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2019 Weber Yann
  3. *
  4. * This file is part of PyFCGI.
  5. *
  6. * PyFCGI is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * PyFCGI is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with PyFCGI. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**@defgroup IPC Inter process communication mechanism
  20. */
  21. /**@file ipc.h
  22. * @ingroup IPC */
  23. #ifndef __IPC_H___
  24. #define __IPC_H___
  25. #include <fcgiapp.h>
  26. #include <fcgi_stdio.h> /* fcgi library; put it first*/
  27. #include <fcntl.h>
  28. #include <semaphore.h>
  29. #include <sys/stat.h>
  30. /**@brief Format for sem and shm */
  31. #define PYFCGI_IPCNAME_FMT "/PyFCGI-%d_%s"
  32. /**@brief Number of semaphores */
  33. #define PYFCGI_NSEM 3
  34. #define SEM_WSTATE 0
  35. #define SEM_WREQS 1
  36. #define SEM_STATS 2
  37. /**@brief Semaphore uniq name */
  38. #define PYFCGI_SEMNAMES {"WState", "WReqs", "SHMStats"}
  39. #define PyFCGI_SEM(i) (PyFCGI_conf.sems[i])
  40. /**@defgroup IPC_flags IPC component flags
  41. * @ingroup IPC
  42. * @brief For IPC component selection */
  43. /**@brief Worker state semaphore
  44. * @ingroup IPC_flags */
  45. #define IPC_WSTATE 2
  46. /**@brief Worker state semaphore
  47. * @ingroup IPC_flags */
  48. #define IPC_WREQS 4
  49. /**@brief Worker state semaphore
  50. * @ingroup IPC_flags */
  51. #define IPC_SEMST 8
  52. /**@brief Worker state semaphore
  53. * @ingroup IPC_flags */
  54. #define IPC_SHMST 16
  55. typedef unsigned short pyfcgi_ipc_flag_t;
  56. #include "conf.h"
  57. /**@brief Set semaphore names using master process PID as uniq key
  58. * @param pid_t master process PID
  59. */
  60. void pyfcgi_name_sems(pid_t master_pid);
  61. /**@brief Do shm_open & sem_open given component indicated by flag
  62. * @param pyfcgi_ipc_flah_t flag a binary or combination of component flags
  63. * @return 0 if no error else -1
  64. * @note Stores the flag in configuration context
  65. * @see IPC_flags
  66. */
  67. int pyfcgi_IPC_init(pyfcgi_ipc_flag_t flag);
  68. /**@brief Same than @ref pyfchi_IPC_init but with O_CREAT flag set */
  69. int pyfcgi_IPC_create(pyfcgi_ipc_flag_t flag);
  70. /**@brief Close previously opened IPC component (from conf context stored flag)
  71. * @return 0 if no error else -1
  72. */
  73. int pyfcgi_IPC_close();
  74. /**@brief IPC ressources cleanup */
  75. int pyfcgi_IPC_destroy(pyfcgi_ipc_flag_t flag);
  76. #endif