pt.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * $Id$
  3. *
  4. * Process Table
  5. *
  6. *
  7. *
  8. * Copyright (C) 2001-2003 Fhg Fokus
  9. *
  10. * This file is part of ser, a free SIP server.
  11. *
  12. * ser is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version
  16. *
  17. * For a license to use the ser software under conditions
  18. * other than those described here, or to purchase support for this
  19. * software, please contact iptel.org by e-mail at the following addresses:
  20. * [email protected]
  21. *
  22. * ser is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  30. */
  31. #ifndef _PT_H
  32. #define _PT_H
  33. #include <sys/types.h>
  34. #include <unistd.h>
  35. #include "globals.h"
  36. #include "timer.h"
  37. #define MAX_PT_DESC 128
  38. struct process_table {
  39. int pid;
  40. #ifdef USE_TCP
  41. int unix_sock; /* unix socket on which tcp main listens */
  42. int idx; /* tcp child index, -1 for other processes */
  43. #endif
  44. char desc[MAX_PT_DESC];
  45. };
  46. extern struct process_table *pt;
  47. extern int process_no;
  48. /* get number of process started by main with
  49. given configuration
  50. */
  51. inline static int process_count()
  52. {
  53. return
  54. /* receivers and attendant */
  55. (dont_fork ? 1 : children_no*sock_no + 1)
  56. /* timer process */
  57. + (timer_list ? 1 : 0 )
  58. /* fifo server */
  59. +((fifo==NULL || strlen(fifo)==0) ? 0 : 1 )
  60. #ifdef USE_TCP
  61. + 1/* tcp main */ + tcp_children_no +
  62. (timer_list ? 0: 1) /* add the timer proc. if not already taken
  63. into account */
  64. #endif
  65. ;
  66. }
  67. /* retun processes's pid */
  68. inline static int my_pid()
  69. {
  70. return pt ? pt[process_no].pid : getpid();
  71. }
  72. #endif