globals.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. /*
  39. * Copyright (c) 1996 Regents of the University of Michigan.
  40. * All rights reserved.
  41. *
  42. * SLAPD globals.c -- SLAPD library global variables
  43. */
  44. #if defined(NET_SSL)
  45. #include "ldap.h"
  46. #include <sslproto.h> /* cipher suite names */
  47. #include <ldap_ssl.h>
  48. #undef OFF
  49. #undef LITTLE_ENDIAN
  50. #endif
  51. #include <stdio.h>
  52. #include <string.h>
  53. #include <sys/types.h>
  54. #include <time.h>
  55. #include <stdarg.h>
  56. #include <stdlib.h>
  57. #if defined( _WIN32 )
  58. #include "ntslapdmessages.h"
  59. #include "proto-ntutil.h"
  60. #else
  61. #include <sys/time.h>
  62. #include <sys/socket.h>
  63. #include <netinet/in.h>
  64. #include <arpa/inet.h>
  65. #include <netdb.h>
  66. #endif
  67. #include "slap.h"
  68. #include "fe.h"
  69. /* On UNIX, there's only one copy of slapd_ldap_debug */
  70. /* On NT, each module keeps its own module_ldap_debug, which */
  71. /* points to the process' slapd_ldap_debug */
  72. #ifdef _WIN32
  73. int *module_ldap_debug;
  74. #endif
  75. int should_detach = 1;
  76. time_t starttime;
  77. PRThread *listener_tid;
  78. Slapi_PBlock *repl_pb = NULL;
  79. /*
  80. * global variables that need mutex protection
  81. */
  82. int active_threads;
  83. PRInt32 ops_initiated;
  84. PRInt32 ops_completed;
  85. PRLock *ops_mutex;
  86. int num_conns;
  87. PRLock *num_conns_mutex;
  88. /*
  89. DEC/COMPAQ has released a patch for 4.0d (e?) which will speed up
  90. malloc/free considerably in multithreaded multiprocessor
  91. applications (like directory server!), sort of like SmartHeap but
  92. not as snazzy. The last three parameters only take effect if the
  93. patch is installed, otherwise they are ignored. The rest of the
  94. parameters are included along with their default values, but they
  95. are commented out except:
  96. unsigned long __noshrink = 1; old - default is 0; apparently this is ignored for now
  97. int __fast_free_max = INT_MAX; old - default is 13; may cause excessive memory consumption
  98. */
  99. #if defined(OSF1) && defined(LDAP_DONT_USE_SMARTHEAP)
  100. /* From an email from Dave Long at DEC/Compaq:
  101. The following is an example of how to tune for maximum speed on a
  102. system with three or more CPUs and with no concern for memory used:
  103. #include <limits.h>
  104. #include <sys/types.h>
  105. */
  106. unsigned long __noshrink = 1; /* old - default is 0; apparently this is ignored for now */
  107. /*
  108. size_t __minshrink = 65536;
  109. double __minshrinkfactor = 0.001;
  110. size_t __mingrow = 65536;
  111. double __mingrowfactor = 0.1;
  112. unsigned long __madvisor = 0;
  113. unsigned long __small_buff = 0;
  114. */
  115. int __fast_free_max = INT_MAX; /* old - default is 13; may cause excessive memory consumption */
  116. /*
  117. unsigned long __sbrk_override = 0;
  118. unsigned long __taso_mode = 0;
  119. */
  120. /*
  121. These are the new parameters
  122. */
  123. int __max_cache = 27;
  124. int __first_fit = 2;
  125. int __delayed_free = 1;
  126. /*
  127. Note that the allowed values for the new __max_cache tuning variable
  128. are: 15, 18, 21, 24, 27. Any other value is likely to actually harm
  129. performance or even cause a core dump.
  130. */
  131. #endif
  132. #if defined( _WIN32 )
  133. /* String constants (no change for international) */
  134. SERVICE_STATUS LDAPServerStatus;
  135. SERVICE_STATUS_HANDLE hLDAPServerServiceStatus;
  136. #endif
  137. Connection_Table *the_connection_table = NULL;
  138. char *pid_file = "/dev/null";
  139. char *start_pid_file = "/dev/null";
  140. char *attr_dataversion = ATTR_DATAVERSION;
  141. extern void set_dll_entry_points( slapdEntryPoints *sep );
  142. void
  143. set_entry_points()
  144. {
  145. slapdEntryPoints *sep;
  146. sep = (slapdEntryPoints *) slapi_ch_malloc( sizeof( slapdEntryPoints ));
  147. sep->sep_ps_wakeup_all = (caddr_t)ps_wakeup_all;
  148. sep->sep_ps_service = (caddr_t)ps_service_persistent_searches;
  149. sep->sep_disconnect_server = (caddr_t)disconnect_server;
  150. sep->sep_slapd_SSL_client_init = (caddr_t)slapd_SSL_client_init;
  151. sep->sep_slapd_ssl_init = (caddr_t)slapd_ssl_init;
  152. sep->sep_slapd_ssl_init2 = (caddr_t)slapd_ssl_init2;
  153. set_dll_entry_points( sep );
  154. }