CUBRID Engine
latest
Main Page
Namespaces
Classes
Files
File List
File Members
master_util.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008 Search Solution Corporation
3
* Copyright 2016 CUBRID Corporation
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
20
/*
21
* master_util.h : common module for commdb and master
22
*
23
*/
24
25
#ifndef _MASTER_UTIL_H_
26
#define _MASTER_UTIL_H_
27
28
#ident "$Id$"
29
30
#include "
connection_defs.h
"
31
32
#if defined(WINDOWS)
33
#define SLEEP_SEC(X) Sleep((X) * 1000)
34
#define SLEEP_MILISEC(sec, msec) Sleep((sec) * 1000 + (msec))
35
#else
36
#define SLEEP_SEC(X) sleep(X)
37
#define SLEEP_MILISEC(sec, msec) \
38
do { \
39
struct timeval sleep_time_val; \
40
sleep_time_val.tv_sec = sec; \
41
sleep_time_val.tv_usec = (msec) * 1000; \
42
select(0, 0, 0, 0, &sleep_time_val); \
43
} while(0)
44
#endif
45
46
// todo: MASTER_ER_... shouldn't be necessary anymore. each thread has own error context
47
#define MASTER_ER_SET(...) \
48
do { \
49
if (css_Master_er_log_enabled == true) { \
50
pthread_mutex_lock (&css_Master_er_log_lock); \
51
er_set (__VA_ARGS__); \
52
pthread_mutex_unlock (&css_Master_er_log_lock); \
53
} \
54
} while (0)
55
56
#define MASTER_ER_SET_WITH_OSERROR(...) \
57
do { \
58
if (css_Master_er_log_enabled == true) { \
59
pthread_mutex_lock (&css_Master_er_log_lock); \
60
er_set_with_oserror (__VA_ARGS__); \
61
pthread_mutex_unlock (&css_Master_er_log_lock); \
62
} \
63
} while (0)
64
65
#define MASTER_ER_LOG_DEBUG(...) \
66
do { \
67
if (css_Master_er_log_enabled == true) { \
68
pthread_mutex_lock (&css_Master_er_log_lock); \
69
er_log_debug (__VA_ARGS__); \
70
pthread_mutex_unlock (&css_Master_er_log_lock); \
71
} \
72
} while (0)
73
74
typedef
struct
socket_queue_entry
SOCKET_QUEUE_ENTRY
;
75
struct
socket_queue_entry
76
{
77
SOCKET
fd
;
78
int
fd_type
;
79
int
db_error
;
80
int
queue_p
;
81
int
info_p
;
82
int
error_p
;
83
int
pid
;
84
char
*
name
;
85
char
*
version_string
;
86
char
*
env_var
;
87
CSS_CONN_ENTRY
*
conn_ptr
;
88
int
port_id
;
89
int
ha_mode
;
90
struct
socket_queue_entry
*
next
;
91
};
92
93
extern
bool
master_util_config_startup
(
const
char
*
db_name
,
int
*
port_id
);
94
extern
void
master_util_wait_proc_terminate
(
int
pid
);
95
96
extern
pthread_mutex_t
css_Master_er_log_lock
;
97
extern
pthread_mutex_t
css_Master_er_log_enable_lock
;
98
extern
bool
css_Master_er_log_enabled
;
99
100
#define GET_REAL_MASTER_CONN_NAME(name) (((char *) name) + 1)
101
#define IS_MASTER_CONN_NAME_DRIVER(name) (*((char *)name) == '-')
102
#define IS_MASTER_CONN_NAME_HA_SERVER(name) (*((char *)name) == '#')
103
#define IS_MASTER_CONN_NAME_HA_COPYLOG(name) (*((char *)name) == '$')
104
#define IS_MASTER_CONN_NAME_HA_APPLYLOG(name) (*((char *)name) == '%')
105
106
#endif
/* _MASTER_UTIL_H_ */
socket_queue_entry::name
char * name
Definition:
master_util.h:84
SOCKET
int SOCKET
Definition:
porting.h:482
socket_queue_entry::conn_ptr
CSS_CONN_ENTRY * conn_ptr
Definition:
master_util.h:87
socket_queue_entry::error_p
int error_p
Definition:
master_util.h:82
css_conn_entry
Definition:
connection_defs.h:423
socket_queue_entry::db_error
int db_error
Definition:
master_util.h:79
master_util_wait_proc_terminate
void master_util_wait_proc_terminate(int pid)
Definition:
master_util.c:72
css_Master_er_log_enabled
bool css_Master_er_log_enabled
Definition:
master.c:131
socket_queue_entry::fd
SOCKET fd
Definition:
master_util.h:77
socket_queue_entry::ha_mode
int ha_mode
Definition:
master_util.h:89
socket_queue_entry::info_p
int info_p
Definition:
master_util.h:81
socket_queue_entry::env_var
char * env_var
Definition:
master_util.h:86
socket_queue_entry::version_string
char * version_string
Definition:
master_util.h:85
socket_queue_entry
Definition:
master_util.h:75
db_name
char * db_name
Definition:
system_parameter.c:6413
socket_queue_entry::pid
int pid
Definition:
master_util.h:83
connection_defs.h
socket_queue_entry::queue_p
int queue_p
Definition:
master_util.h:80
master_util_config_startup
bool master_util_config_startup(const char *db_name, int *port_id)
Definition:
master_util.c:42
socket_queue_entry::fd_type
int fd_type
Definition:
master_util.h:78
css_Master_er_log_enable_lock
pthread_mutex_t css_Master_er_log_enable_lock
Definition:
master.c:130
socket_queue_entry::next
struct socket_queue_entry * next
Definition:
master_util.h:90
socket_queue_entry::port_id
int port_id
Definition:
master_util.h:88
css_Master_er_log_lock
pthread_mutex_t css_Master_er_log_lock
Definition:
master.c:129
src
executables
master_util.h
Generated by
1.8.11