You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.6 KiB

  1. /* Copyright (C) 2007 Google Inc.
  2. Copyright (C) 2008 MySQL AB
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  13. #ifndef SEMISYNC_H
  14. #define SEMISYNC_H
  15. #include <stdint.h>
  16. #include <string.h>
  17. #include <assert.h>
  18. #include <sys/time.h>
  19. #include <time.h>
  20. #include <stdio.h>
  21. #include <pthread.h>
  22. #include <mysql.h>
  23. typedef uint32_t uint32;
  24. typedef unsigned long long my_off_t;
  25. #define FN_REFLEN 512 /* Max length of full path-name */
  26. void sql_print_error(const char *format, ...);
  27. void sql_print_warning(const char *format, ...);
  28. void sql_print_information(const char *format, ...);
  29. extern unsigned long max_connections;
  30. #define MYSQL_SERVER
  31. #define HAVE_REPLICATION
  32. #include <my_global.h>
  33. #include <my_pthread.h>
  34. #include <mysql/plugin.h>
  35. #include <replication.h>
  36. typedef struct st_mysql_show_var SHOW_VAR;
  37. typedef struct st_mysql_sys_var SYS_VAR;
  38. /**
  39. This class is used to trace function calls and other process
  40. information
  41. */
  42. class Trace {
  43. public:
  44. static const unsigned long kTraceFunction;
  45. static const unsigned long kTraceGeneral;
  46. static const unsigned long kTraceDetail;
  47. static const unsigned long kTraceNetWait;
  48. unsigned long trace_level_; /* the level for tracing */
  49. inline void function_enter(const char *func_name)
  50. {
  51. if (trace_level_ & kTraceFunction)
  52. sql_print_information("---> %s enter", func_name);
  53. }
  54. inline int function_exit(const char *func_name, int exit_code)
  55. {
  56. if (trace_level_ & kTraceFunction)
  57. sql_print_information("<--- %s exit (%d)", func_name, exit_code);
  58. return exit_code;
  59. }
  60. Trace()
  61. :trace_level_(0L)
  62. {}
  63. Trace(unsigned long trace_level)
  64. :trace_level_(trace_level)
  65. {}
  66. };
  67. /**
  68. Base class for semi-sync master and slave classes
  69. */
  70. class ReplSemiSyncBase
  71. :public Trace {
  72. public:
  73. static const char kSyncHeader[2]; /* three byte packet header */
  74. /* Constants in network packet header. */
  75. static const unsigned char kPacketMagicNum;
  76. static const unsigned char kPacketFlagSync;
  77. };
  78. #endif /* SEMISYNC_H */