pt.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * $Id$
  3. *
  4. * Process Table
  5. *
  6. *
  7. *
  8. * Copyright (C) 2001-2003 FhG Fokus
  9. *
  10. * Permission to use, copy, modify, and distribute this software for any
  11. * purpose with or without fee is hereby granted, provided that the above
  12. * copyright notice and this permission notice appear in all copies.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  15. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  16. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  17. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  18. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  19. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  20. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21. */
  22. /*
  23. * History:
  24. * --------
  25. * 2003-04-15 added tcp_disable support (andrei)
  26. * 2006-06-14 added process table in shared mem (dragos)
  27. * 2007-07-04 added register_fds() and get_max_open_fds(() (andrei)
  28. */
  29. /** internal fork functions and process table.
  30. * @file: pt.h
  31. * @ingroup core
  32. */
  33. #ifndef _PT_H
  34. #define _PT_H
  35. #include <sys/types.h>
  36. #include <unistd.h>
  37. #include <stdlib.h>
  38. #include "globals.h"
  39. #include "timer.h"
  40. #include "socket_info.h"
  41. #include "locking.h"
  42. #define MAX_PT_DESC 128
  43. struct process_table {
  44. int pid;
  45. #ifdef USE_TCP
  46. int unix_sock; /* unix socket on which tcp main listens */
  47. int idx; /* tcp child index, -1 for other processes */
  48. #endif
  49. char desc[MAX_PT_DESC];
  50. };
  51. extern struct process_table *pt;
  52. extern gen_lock_t* process_lock;
  53. extern int *process_count;
  54. extern int process_no;
  55. extern struct tcp_child* tcp_children;
  56. int init_pt(int proc_no);
  57. int get_max_procs(void);
  58. int register_procs(int no);
  59. int get_max_open_fds(void);
  60. int register_fds(int no);
  61. int close_extra_socks(int proc_id, int proc_no);
  62. #define get_proc_no() ((process_count)?*process_count:0)
  63. /* return processes pid */
  64. int my_pid(void);
  65. /**
  66. * Forks a new process.
  67. * @param desc - text description for the process table
  68. * @param make_sock - if to create a unix socket pair for it
  69. * @returns the pid of the new process
  70. */
  71. int fork_process(int child_id,char *desc,int make_sock);
  72. /**
  73. * Forks a new TCP process.
  74. * @param desc - text description for the process table
  75. * @param r - index in the tcp_children array
  76. * @param *reader_fd_1 - pointer to return the reader_fd[1]
  77. * @returns the pid of the new process
  78. */
  79. #ifdef USE_TCP
  80. int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1);
  81. #endif
  82. #ifdef PKG_MALLOC
  83. void mem_dump_pkg_cb(str *gname, str *name);
  84. #endif
  85. #ifdef SHM_MEM
  86. int mem_dump_shm_fixup(void *handle, str *gname, str *name, void **val);
  87. #endif
  88. unsigned int set_fork_delay(unsigned int v);
  89. #endif