globals.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. /*
  42. * Copyright (c) 1996 Regents of the University of Michigan.
  43. * All rights reserved.
  44. *
  45. * SLAPD globals.c -- SLAPD library global variables
  46. */
  47. #include "ldap.h"
  48. #include <sslproto.h> /* cipher suite names */
  49. #include <ldap_ssl.h>
  50. #undef OFF
  51. #undef LITTLE_ENDIAN
  52. #include <stdio.h>
  53. #include <string.h>
  54. #include <sys/types.h>
  55. #include <time.h>
  56. #include <stdarg.h>
  57. #include <stdlib.h>
  58. #if defined( _WIN32 )
  59. #include "ntslapdmessages.h"
  60. #include "proto-ntutil.h"
  61. #else
  62. #include <sys/time.h>
  63. #include <sys/socket.h>
  64. #include <netinet/in.h>
  65. #include <arpa/inet.h>
  66. #include <netdb.h>
  67. #endif
  68. #include "slap.h"
  69. #include "fe.h"
  70. /* On UNIX, there's only one copy of slapd_ldap_debug */
  71. /* On NT, each module keeps its own module_ldap_debug, which */
  72. /* points to the process' slapd_ldap_debug */
  73. #ifdef _WIN32
  74. int *module_ldap_debug;
  75. #endif
  76. int should_detach = 1;
  77. time_t starttime;
  78. PRThread *listener_tid;
  79. Slapi_PBlock *repl_pb = NULL;
  80. /*
  81. * global variables that need mutex protection
  82. */
  83. Slapi_Counter *ops_initiated;
  84. Slapi_Counter *ops_completed;
  85. Slapi_Counter *num_conns;
  86. /*
  87. DEC/COMPAQ has released a patch for 4.0d (e?) which will speed up
  88. malloc/free considerably in multithreaded multiprocessor
  89. applications (like directory server!), sort of like SmartHeap but
  90. not as snazzy. The last three parameters only take effect if the
  91. patch is installed, otherwise they are ignored. The rest of the
  92. parameters are included along with their default values, but they
  93. are commented out except:
  94. unsigned long __noshrink = 1; old - default is 0; apparently this is ignored for now
  95. int __fast_free_max = INT_MAX; old - default is 13; may cause excessive memory consumption
  96. */
  97. #if defined(OSF1) && defined(LDAP_DONT_USE_SMARTHEAP)
  98. /* From an email from Dave Long at DEC/Compaq:
  99. The following is an example of how to tune for maximum speed on a
  100. system with three or more CPUs and with no concern for memory used:
  101. #include <limits.h>
  102. #include <sys/types.h>
  103. */
  104. unsigned long __noshrink = 1; /* old - default is 0; apparently this is ignored for now */
  105. /*
  106. size_t __minshrink = 65536;
  107. double __minshrinkfactor = 0.001;
  108. size_t __mingrow = 65536;
  109. double __mingrowfactor = 0.1;
  110. unsigned long __madvisor = 0;
  111. unsigned long __small_buff = 0;
  112. */
  113. int __fast_free_max = INT_MAX; /* old - default is 13; may cause excessive memory consumption */
  114. /*
  115. unsigned long __sbrk_override = 0;
  116. unsigned long __taso_mode = 0;
  117. */
  118. /*
  119. These are the new parameters
  120. */
  121. int __max_cache = 27;
  122. int __first_fit = 2;
  123. int __delayed_free = 1;
  124. /*
  125. Note that the allowed values for the new __max_cache tuning variable
  126. are: 15, 18, 21, 24, 27. Any other value is likely to actually harm
  127. performance or even cause a core dump.
  128. */
  129. #endif
  130. #if defined( _WIN32 )
  131. /* String constants (no change for international) */
  132. SERVICE_STATUS LDAPServerStatus;
  133. SERVICE_STATUS_HANDLE hLDAPServerServiceStatus;
  134. #endif
  135. Connection_Table *the_connection_table = NULL;
  136. char *pid_file = "/dev/null";
  137. char *start_pid_file = "/dev/null";
  138. char *attr_dataversion = ATTR_DATAVERSION;
  139. extern void set_dll_entry_points( slapdEntryPoints *sep );
  140. void
  141. set_entry_points()
  142. {
  143. slapdEntryPoints *sep;
  144. sep = (slapdEntryPoints *) slapi_ch_malloc( sizeof( slapdEntryPoints ));
  145. sep->sep_ps_wakeup_all = (caddr_t)ps_wakeup_all;
  146. sep->sep_ps_service = (caddr_t)ps_service_persistent_searches;
  147. sep->sep_disconnect_server = (caddr_t)disconnect_server;
  148. sep->sep_slapd_ssl_init = (caddr_t)slapd_ssl_init;
  149. sep->sep_slapd_ssl_init2 = (caddr_t)slapd_ssl_init2;
  150. set_dll_entry_points( sep );
  151. /* To apply the nsslapd-counters config value properly,
  152. these values are initialized here after config file is read */
  153. if (config_get_slapi_counters()) {
  154. ops_initiated = slapi_counter_new();
  155. ops_completed = slapi_counter_new();
  156. g_set_num_entries_sent( slapi_counter_new() );
  157. g_set_num_bytes_sent( slapi_counter_new() );
  158. } else {
  159. ops_initiated = NULL;
  160. ops_completed = NULL;
  161. g_set_num_entries_sent( NULL );
  162. g_set_num_bytes_sent( NULL );
  163. }
  164. }